Blockchain business transaction execution method, device, equipment and readable storage medium
By collecting device information in the consensus node of the blockchain to calculate the parallelism degree and execute business transactions in parallel, the performance degradation caused by simply improving parallelism is solved, and more efficient transaction execution performance is achieved.
Patent Information
- Application Number
- CN202111572625.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-21
- Publication Date
- 2025-06-24
- Estimated Expiration
- 2041-12-21
AI Technical Summary
When simply increasing the parallelism of blockchain transactions to improve execution performance, excessive parallelism may lead to increased resource switching costs and reduced performance.
By collecting device information in the consensus node of the alliance chain, recording it in the smart contract, a reasonable degree of parallelism is calculated, and multiple threads are started to execute business transactions in parallel according to this degree of parallelism, avoiding excessive parallelism.
The overall computing resources of each consensus node in the alliance chain are comprehensively considered, which avoids performance degradation caused by simply improving parallelism and improves transaction execution performance.
Smart Images

Figure CN114237900B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of fintech, and in particular, to a method, device, equipment and readable storage medium for executing blockchain business transactions. Background Art
[0002] Blockchain technology was initially mainly used as a distributed ledger, and the most typical scenario is the transfer scenario. The transfer scenario is a high-frequency scenario, especially the scenario of multi-account to single-account transfer. When applying blockchain to the scenario of multi-to-one transfer, the performance requirements for blockchain transaction execution are relatively high. At present, some transaction parallel execution mechanisms can be used to improve the performance of blockchain transaction execution. However, simply increasing the parallelism cannot continuously improve the transaction execution performance, and excessive parallelism will lead to mutual competition for resource preemption, resulting in a high resource switching cost and a decline in performance. Summary of the Invention
[0003] The main purpose of the present invention is to provide a method, device, equipment and readable storage medium for executing blockchain business transactions, aiming to solve the technical problem that the method of simply improving the parallelism to improve the performance of blockchain transaction execution may lead to a decline in performance due to excessive parallelism.
[0004] To achieve the above object, the present invention provides a method for executing blockchain business transactions, which is applied to consensus nodes in a consortium chain, and the method includes the following steps:
[0005] Collect the first device information of the local node and report the first device information as the first information when submitting a transaction;
[0006] Record the first device information in the smart contract according to the first information report transaction submitted, and broadcast the first information report transaction to other consensus nodes in the consortium chain;
[0007] Receive the second information report transactions broadcast by other consensus nodes, and record the second device information of other consensus nodes in the second information report transactions in the smart contract;
[0008] Calculate the parallelism according to the device information of each consensus node recorded in the smart contract, and record the parallelism in the smart contract;
[0009] When executing the business transactions in the target block, start multiple threads to execute each business transaction in the target block in parallel according to the parallelism recorded in the smart contract.
[0010] Optionally, the step of calculating the parallelism according to the device information of each consensus node recorded in the smart contract includes:
[0011] Calculate the performance metric value of the i-th consensus node based on the device information of the i-th consensus node recorded in the smart contract;
[0012] After sorting the performance metric values of each consensus node in descending order, select the minimum performance metric value among the top n - f performance metric values, where n is the number of consensus nodes in the consortium blockchain and 3f + 1 = n;
[0013] Calculate the degree of parallelism based on the minimum performance metric value.
[0014] Optionally, the device information of the i-th consensus node includes the number of CPUs and the CPU frequency of the i-th consensus node;
[0015] The step of calculating the performance metric value of the i-th consensus node based on the device information of the i-th consensus node recorded in the smart contract includes:
[0016] Multiply the number of CPUs and the CPU frequency of the i-th consensus node recorded in the smart contract to obtain the first performance metric value of the i-th consensus node;
[0017] Use the number of CPUs of the i-th consensus node recorded in the smart contract as the second performance metric value of the i-th consensus node;
[0018] The step of selecting the minimum performance metric value among the top n - f performance metric values after sorting the performance metric values of each consensus node in descending order includes:
[0019] After sorting the first performance metric values of each consensus node in descending order, select the minimum first performance metric value among the top n - f first performance metric values;
[0020] After sorting the second performance metric values of each consensus node in descending order, select the minimum second performance metric value among the top n - f second performance metric values;
[0021] The step of calculating the degree of parallelism based on the minimum performance metric value includes:
[0022] Divide the minimum first performance metric value by the minimum second performance metric value and then round it to obtain the degree of parallelism.
[0023] Optionally, the step of starting multiple threads to execute each business transaction in the target block in parallel according to the degree of parallelism recorded in the smart contract includes:
[0024] Divide each business transaction in the target block to obtain multiple transaction sets, where each transaction set contains at least one business transaction, and the number of transaction sets is the same as the parallelism recorded in the smart contract;
[0025] Start a thread for each of the transaction sets, and execute the corresponding transaction set in parallel through each thread, where each thread executes each business transaction in the corresponding transaction set in a serial manner.
[0026] Optionally, the step of dividing each business transaction in the target block to obtain multiple transaction sets includes:
[0027] For any target business transaction in the target block, take the modulo of the index of the target business transaction in the target block by the parallelism recorded in the smart contract to obtain a modulo result;
[0028] Determine the target sub-account number corresponding to the target business transaction according to the modulo result, so as to use the transfer sub-account corresponding to the target sub-account number as the receiving account of the target business transaction when executing the target business transaction;
[0029] Construct each business transaction corresponding to the same sub-account number into a transaction set.
[0030] Optionally, the step of executing the target business transaction includes:
[0031] Detect whether the transfer sub-account corresponding to the target sub-account number exists through the smart contract;
[0032] If it exists, use the transfer sub-account corresponding to the target sub-account number as the receiving account of the target business transaction to execute the transaction;
[0033] If it does not exist, create a transfer sub-account through the smart contract as the transfer sub-account corresponding to the target sub-account number, and use the transfer sub-account corresponding to the target sub-account number as the receiving account of the target business transaction to execute the transaction.
[0034] Optionally, the step of broadcasting the first information reporting transaction to other consensus nodes in the consortium chain includes:
[0035] Sign the first information reporting transaction with the private key of this node, and broadcast the signed first information reporting transaction to other consensus nodes in the consortium chain;
[0036] The step of recording the second device information of other consensus nodes in the second information reporting transaction in the smart contract includes:
[0037] Use the public keys of other consensus nodes to verify the signature of the signed second information reporting transaction. When the signature verification passes, record the second device information of other consensus nodes in the second information reporting transaction in the smart contract.
[0038] To achieve the above object, the present invention further provides a blockchain business transaction execution device, which is deployed on a consensus node in a consortium blockchain. The device includes:
[0039] An information collection module, configured to collect the first device information of the local node and submit the first device information as a first information reporting transaction;
[0040] A contract module, configured to record the first device information in the smart contract according to the submitted first information reporting transaction, and broadcast the first information reporting transaction to other consensus nodes in the consortium blockchain;
[0041] The contract module is further configured to receive the second information reporting transactions broadcast by other consensus nodes, and record the second device information of other consensus nodes in the second information reporting transactions in the smart contract;
[0042] The contract module is further configured to calculate a parallelism degree according to the device information of each consensus node recorded in the smart contract, and record the parallelism degree in the smart contract;
[0043] A parallel execution module, configured to, when executing the business transactions in the target block, start multiple threads to execute the respective business transactions in the target block in parallel according to the parallelism degree recorded in the smart contract.
[0044] To achieve the above object, the present invention further provides a blockchain business transaction execution device, which includes: a memory, a processor, and a blockchain business transaction execution program stored on the memory and executable on the processor. When the blockchain business transaction execution program is executed by the processor, the steps of the above-mentioned blockchain business transaction execution method are implemented.
[0045] In addition, to achieve the above object, the present invention further proposes a computer-readable storage medium, on which a blockchain business transaction execution program is stored. When the blockchain business transaction execution program is executed by a processor, the steps of the above-mentioned blockchain business transaction execution method are implemented.
[0046] In the present invention, the consensus node collects the device information of its own node and submits the device information as an information reporting transaction. According to the submitted information reporting transaction, the device information is recorded in the smart contract, and the information reporting transaction is broadcast to other consensus nodes in the consortium blockchain; receives the information reporting transactions broadcast by other consensus nodes, and records the device information of other consensus nodes in the information reporting transaction in the smart contract; calculates the parallelism according to the device information of each consensus node recorded in the smart contract, and records the parallelism in the smart contract; when executing the business transactions in the target block, starts multiple threads to execute each business transaction in the target block in parallel according to the parallelism recorded in the smart contract. By calculating the parallelism according to the device information of each consensus node and executing each business transaction in parallel according to the calculated parallelism, the present invention comprehensively considers the overall computing resources of each consensus node in the consortium blockchain, and avoids the situation that the performance decreases due to excessive parallelism caused by simply increasing the parallelism. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 It is a schematic structural diagram of the hardware operating environment involved in the solution of the embodiment of the present invention;
[0048] Figure 2 It is a schematic flowchart of the first embodiment of the blockchain business transaction execution method of the present invention;
[0049] Figure 3 It is a schematic diagram of a system framework involved in the embodiment of the present invention;
[0050] Figure 4 It is a schematic diagram of the function modules of the preferred embodiment of the blockchain business transaction execution device of the present invention.
[0051] The realization, functional features and advantages of the object of the present invention will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0052] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0053] DEFINITIONS OF ABBREVIATIONS AND KEY TERMS:
[0054] Smart contract: A program deployed on the blockchain to complete specific functions. This program will be executed by all nodes on the blockchain and ensure the consistency of the program execution results through a consensus algorithm. For example, a transfer contract can record the account balance of users on the blockchain and provide relevant transfer and query interfaces.
[0055] Transaction: An operation request initiated by a user to call a smart contract. The transaction is sent to the blockchain to call a certain interface on the smart contract, triggering the execution of the smart contract code.
[0056] Block: The unit for batch processing of transactions. Multiple transactions are packed into a block to form a batch, which is executed by nodes. Nodes take the block execution as the rhythm and consensus on the execution results.
[0057] API: Application Programming Interface (also known as: Application Programming Interface, foreign name: Application Programming Interface), abbreviated as API, is an agreement for connecting different components of a software system.
[0058] PBFT is the abbreviation of Practical Byzantine Fault Tolerance, that is: Practical Byzantine Fault Tolerance algorithm.
[0059] Parallel execution: On a multi-core machine, multiple tasks are processed simultaneously within the same time period, which can improve the execution performance.
[0060] As Figure 1 shown, Figure 1 is a schematic diagram of the device structure of the hardware operating environment involved in the solution of the embodiment of the present invention.
[0061] It should be noted that the blockchain business transaction execution device in the embodiment of the present invention can be a consensus node in a consortium chain, and no specific limitation is made here.
[0062] As Figure 1 shown, the blockchain business transaction execution device may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, and a communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display) and an input unit such as a keyboard (Keyboard). Optionally, the user interface 1003 may further include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory or a stable memory (non-volatile memory), such as a disk memory. Optionally, the memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0063] Those skilled in the art can understand, Figure 1The device structure shown does not limit the blockchain business transaction execution device, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0064] As Figure 1 shown, in the memory 1005 as a computer storage medium, an operating system, a network communication module, a user interface module, and a blockchain business transaction execution program may be included. The operating system is a program that manages and controls the device's hardware and software resources, and supports the operation of the blockchain business transaction execution program and other software or programs. In the Figure 1 device shown, the user interface 1003 is mainly used for data communication with the client; the network interface 1004 is mainly used for establishing a communication connection with the server; and the processor 1001 may be used to call the blockchain business transaction execution program stored in the memory 1005 and perform the following operations:
[0065] Collect the first device information of this node and report the first device information as the first information for transaction submission;
[0066] Record the first device information in the smart contract according to the first information reporting transaction submitted, and broadcast the first information reporting transaction to other consensus nodes in the consortium chain;
[0067] Receive the second information reporting transactions broadcast by other consensus nodes, and record the second device information of other consensus nodes in the second information reporting transactions in the smart contract;
[0068] Calculate the parallelism according to the device information of each consensus node recorded in the smart contract, and record the parallelism in the smart contract;
[0069] When executing the business transactions in the target block, start multiple threads to execute each business transaction in the target block in parallel according to the parallelism recorded in the smart contract.
[0070] Furthermore, the operation of calculating the parallelism according to the device information of each consensus node recorded in the smart contract includes:
[0071] Calculate the performance metric value of the i-th consensus node according to the device information of the i-th consensus node recorded in the smart contract;
[0072] After sorting the performance metric values of each consensus node in descending order, select the minimum performance metric value among the top n - f performance metric values, where n is the number of consensus nodes in the consortium chain and 3f + 1 = n;
[0073] Calculate the parallelism according to the minimum performance metric value.
[0074] Further, the device information of the i-th consensus node includes the number of CPUs and the CPU frequency of the i-th consensus node;
[0075] The operation of calculating the performance metric value of the i-th consensus node based on the device information of the i-th consensus node recorded in the smart contract includes:
[0076] Multiply the number of CPUs and the CPU frequency of the i-th consensus node recorded in the smart contract to obtain the first performance metric value of the i-th consensus node;
[0077] Take the number of CPUs of the i-th consensus node recorded in the smart contract as the second performance metric value of the i-th consensus node;
[0078] The operation of selecting the minimum performance metric value among the top n - f performance metric values after sorting the performance metric values of each consensus node from largest to smallest includes:
[0079] Sort the first performance metric values of each consensus node from largest to smallest, and select the minimum first performance metric value among the top n - f first performance metric values;
[0080] Sort the second performance metric values of each consensus node from largest to smallest, and select the minimum second performance metric value among the top n - f second performance metric values;
[0081] The operation of calculating the parallelism based on the minimum performance metric value includes:
[0082] Divide the minimum first performance metric value by the minimum second performance metric value and round it to obtain the parallelism.
[0083] Further, the operation of starting multiple threads to execute each business transaction in the target block in parallel according to the parallelism recorded in the smart contract includes:
[0084] Divide each business transaction in the target block into multiple transaction sets, where each transaction set contains at least one business transaction, and the number of transaction sets is the same as the parallelism recorded in the smart contract;
[0085] Start a thread for each transaction set respectively, and execute the corresponding transaction set in parallel through each thread, where each thread executes each business transaction in the corresponding transaction set in a serial manner.
[0086] Further, the operation of dividing each business transaction in the target block into multiple transaction sets includes:
[0087] For any target business transaction in the target block, take the modulus of the index of the target business transaction in the target block with respect to the parallelism recorded in the smart contract to obtain a modulus result;
[0088] Determine the target sub-account number corresponding to the target business transaction according to the modulus result, so as to use the transfer sub-account corresponding to the target sub-account number as the receiving account of the target business transaction when executing the target business transaction;
[0089] Construct each business transaction corresponding to the same sub-account number into a transaction set.
[0090] Further, the operation of executing the target business transaction includes:
[0091] Detect whether the transfer sub-account corresponding to the target sub-account number exists through the smart contract;
[0092] If it exists, use the transfer sub-account corresponding to the target sub-account number as the receiving account of the target business transaction to execute the transaction;
[0093] If it does not exist, create a transfer sub-account through the smart contract as the transfer sub-account corresponding to the target sub-account number, and use the transfer sub-account corresponding to the target sub-account number as the receiving account of the target business transaction to execute the transaction.
[0094] Further, the operation of broadcasting the first information reporting transaction to other consensus nodes in the consortium chain includes:
[0095] Sign the first information reporting transaction with the private key of this node, and broadcast the signed first information reporting transaction to other consensus nodes in the consortium chain;
[0096] The operation of recording the second device information of other consensus nodes in the second information reporting transaction in the smart contract includes:
[0097] Verify the signature of the signed second information reporting transaction with the public keys of other consensus nodes, and record the second device information of other consensus nodes in the second information reporting transaction in the smart contract when the signature verification passes.
[0098] Based on the above structure, various embodiments of the blockchain business transaction execution method are proposed.
[0099] Refer to Figure 2 , Figure 2 It is a schematic flowchart of the first embodiment of the blockchain business transaction execution method of the present invention.
[0100] An embodiment of the present invention provides an embodiment of a blockchain business transaction execution method. It should be noted that although the logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than here. In this embodiment, the execution subject of the blockchain business transaction execution method may be a consensus node in a consortium blockchain, and each consensus node respectively executes the blockchain business transaction execution method of this embodiment. The method includes the following steps:
[0101] Step S10, collect the first device information of this node and report the first device information as the first information for transaction submission;
[0102] In this embodiment, considering that PBFT is generally used in a consortium blockchain for consensus, the consensus scope is determined, and the performance of the chain is jointly determined by the participating nodes. The performance improvement of a single node does not necessarily bring an overall performance improvement. Instead, it is necessary to consider the performance of all consensus nodes to jointly determine the parallelism. Therefore, to solve the technical problem that the method of simply improving the parallelism to enhance the performance of blockchain transaction execution may lead to performance degradation due to excessive parallelism, this embodiment proposes a method for jointly calculating the parallelism by all consensus nodes in a consortium blockchain and performing transaction execution, reasonably allocating the number of parallelisms, and achieving the purpose of reasonably using the resources of each node in the chain and enhancing the performance of chain transaction execution.
[0103] The consensus node collects the device information of this node (hereinafter, the device information of this node is referred to as the first device information to distinguish it from the device information of other consensus nodes). The device information may include information related to the hardware computing resources of this node. For example, the number of CPUs, CPU frequency, etc. are not specifically limited in this embodiment.
[0104] The consensus node submits the first device information of this node as a transaction. This transaction is specifically used to report device information and is different from the business transactions submitted by clients in a business scenario. Therefore, to show the difference below, this transaction is called an information reporting transaction, and the information reporting transaction submitted by this node is called the first information reporting transaction to distinguish it from the information reporting transactions of other consensus nodes. Among them, submitting the first information reporting transaction means submitting it to this node. Collecting the first device information of this node can be collected through the API provided by the operating system and is not limited here.
[0105] It can be understood that other consensus nodes also execute the blockchain business transaction execution method of this embodiment, so they will also collect their respective device information and submit it as an information reporting transaction. Hereinafter, the device information and information reporting transactions of other nodes are respectively called the second device information and the second information reporting transaction for distinction.
[0106] Step S20, record the first device information in the smart contract according to the first information reporting transaction submitted, and broadcast the first information reporting transaction to each other consensus node in the consortium blockchain;
[0107] When a consensus node in the consortium blockchain receives a business transaction, it will broadcast the transaction to other consensus nodes in the consortium blockchain. In this embodiment, taking advantage of this feature, the first device information of this node is submitted to this node as the first information reporting transaction by the consensus node. After receiving the first information reporting transaction, this node broadcasts the first information reporting transaction to each other consensus node in the consortium blockchain. It can be understood that other consensus nodes also execute the blockchain business transaction execution method of this embodiment, so other nodes will also broadcast their respective second information reporting transactions.
[0108] After receiving the submitted first information reporting transaction, the consensus node will also record the first device information in the first information reporting transaction in the smart contract for subsequent use.
[0109] Step S30, receive the second information reporting transactions broadcast by each other consensus node, and record the second device information of each other consensus node in the second information reporting transaction in the smart contract;
[0110] The consensus node respectively receives the second information reporting transactions broadcast by each other consensus node, extracts the second device information of each other consensus node from each second information reporting transaction respectively, and records each second device information in the smart contract. For example, if there are four consensus nodes in the consortium blockchain, each consensus node will record its own first device information and the second device information of the other three consensus nodes in the smart contract of this node. That is, each consensus node will record four device information in the smart contract of this node, and the device information in the smart contracts of each consensus node is the same.
[0111] Step S40, calculate the parallelism according to the device information of each consensus node recorded in the smart contract, and record the parallelism in the smart contract;
[0112] After the consensus node records the device information of each consensus node in the smart contract, it can calculate the parallelism according to the device information of each consensus node. Specifically, calculating the parallelism according to the device information of each consensus node can consider the device computing resource situation of each node, determine a reasonable parallelism, and avoid excessive parallelism resulting in mutual competition for resource preemption, leading to a decrease in resource switching cost and performance.
[0113] In one embodiment, the parallelism that can be supported by the devices of each consensus node under the reasonable utilization of hardware resources can be determined according to the device information of each consensus node, and the smallest parallelism among the various parallelisms can be selected as the calculated parallelism.
[0114] After calculating the parallelism, the consensus node can record the parallelism in the smart contract for subsequent parallel execution of business transactions according to the parallelism extracted from the smart contract.
[0115] It should be noted that the method for each consensus node to calculate the parallelism according to the respective device information is the same. Therefore, the parallelisms calculated by each consensus node are the same, and thus the parallelisms recorded in their respective smart contracts are also the same.
[0116] Step S50, when executing the business transactions in the target block, start multiple threads to execute each business transaction in the target block in parallel according to the parallelism recorded in the smart contract.
[0117] A consensus node in the consortium chain serves as a packaging node, packages multiple business transactions from the transaction pool to obtain a block, and broadcasts the block to other consensus nodes. Each consensus node executes each business transaction in the block. When a consensus node executes the business transactions in a certain block (hereinafter referred to as the target block for distinction), it can start multiple threads to execute each business transaction in parallel according to the parallelism recorded in the smart contract. Among them, the number of threads started is the same as the parallelism, so as to achieve parallel execution of each business transaction according to this parallelism. It should be noted that the conflict-free transactions in each business transaction can be executed in parallel by different threads to avoid conflicts when executing each business transaction in parallel. For each business transaction assigned to the same thread, the thread can execute each business transaction in sequence in a serial manner.
[0118] In one embodiment, when the device information of the consensus node is updated, it can be re-collected and reported to update the device information of the consensus node in the smart contract, calculate a new parallelism according to the updated device information in the smart contract, and perform parallel execution of business transactions according to the new parallelism.
[0119] In one embodiment, such as Figure 3As shown, the consensus node may include an information collection module, a contract module, and a parallel execution module. Among them, the consensus node collects the first device information of this node through the information collection module and submits it as a first information reporting transaction to the contract module. The information collection module can construct a call transaction of the information collection function of the contract module with the first device information as a parameter, so as to realize submitting the first device information as a first information reporting transaction to the contract module. After the consensus node submits the first information reporting transaction to the contract module through the information collection module, it broadcasts the first information reporting transaction to other consensus nodes through the contract module, and can receive the second information reporting transactions broadcast by other consensus nodes through the contract module, and record the second device information in the second information reporting transaction in the smart contract. The consensus node can calculate the parallelism according to the device information of each consensus node recorded in the smart contract through the contract module and record the parallelism in the smart contract. The consensus node can read the parallelism recorded in the smart contract through the parallel execution module and execute the business transaction according to the parallelism.
[0120] In this embodiment, the device information of this node is collected by the consensus node and submitted as an information reporting transaction. According to the submitted information reporting transaction, the device information is recorded in the smart contract, and the information reporting transaction is broadcast to other consensus nodes in the consortium chain; receive the information reporting transactions broadcast by other consensus nodes, and record the device information of other consensus nodes in the information reporting transaction in the smart contract; calculate the parallelism according to the device information of each consensus node recorded in the smart contract and record the parallelism in the smart contract; when executing the business transactions in the target block, start multiple threads to execute each business transaction in the target block in parallel according to the parallelism recorded in the smart contract. In this embodiment, the parallelism is calculated according to the device information of each consensus node, and each business transaction is executed in parallel according to the calculated parallelism, comprehensively considering the overall computing resources of each consensus node in the consortium chain, avoiding the situation that the performance decreases due to excessive parallelism caused by simply increasing the parallelism, and also avoiding the situation that the storage consumption increases exponentially due to simply increasing the parallelism. Moreover, by submitting the collected device information as an information reporting transaction, broadcasting the information reporting transaction to other consensus nodes, and recording the device information in the smart contract, the consistency of the parallelism calculation of each consensus node is realized by using the characteristics of the smart contract, thus ensuring the consistency of the improvement of the transaction execution performance of each consensus node.
[0121] Further, in an implementation manner, the step of broadcasting the first information reporting transaction to other consensus nodes in the consortium chain in step S20 includes:
[0122] Step S201: Sign the first information reporting transaction with the private key of this node, and broadcast the signed first information reporting transaction to other consensus nodes in the consortium blockchain;
[0123] After receiving the first information reporting transaction submitted by this node, the consensus node can first sign the first information reporting transaction with the private key of this node, and then broadcast the signed first information reporting transaction to other consensus nodes. Specifically, the method of signing the first information reporting transaction with the private key can be to calculate the digest of the first information reporting transaction using a digest algorithm, and encrypt the digest with the private key to obtain a digital signature; broadcasting the signed first information reporting transaction to other consensus nodes specifically means broadcasting the digital signature and the first information reporting transaction to each consensus node together.
[0124] The consensus node can pre - send the public key of this node to other consensus nodes, so that after other consensus nodes receive the signed first information reporting transaction, they can use this public key to verify the signature of the signed first information reporting transaction, and record the first device information in the first information reporting transaction in their respective smart contracts after the signature verification passes.
[0125] The step of recording the second device information of other consensus nodes in the second information reporting transaction in the smart contract in step S30 includes:
[0126] Step S301: Verify the signature of the signed second information reporting transaction using the public keys of other consensus nodes, and record the second device information of other consensus nodes in the second information reporting transaction in the smart contract when the signature verification passes.
[0127] After receiving the signed second information reporting transaction broadcast by other consensus nodes, the consensus node can first verify the signature of the signed second information reporting transaction. When the signature verification passes, it indicates that the second information reporting transaction is indeed sent by other consensus nodes. At this time, record the second device information in the second information reporting transaction in the smart contract of this node.
[0128] Among them, other consensus nodes can first send their respective public keys to this node. When this node verifies the signature of the signed second information reporting transaction, it first decrypts the digital signature therein using the public key of the corresponding consensus node, and then calculates the digest of the received second information reporting transaction using the same digest algorithm, and compares it with the decrypted result. If they are consistent, it is determined that the signature verification passes; otherwise, it is determined that the signature verification fails.
[0129] In one embodiment, if the consensus node fails to pass the signature verification of the second information reported transaction received, the transaction can be discarded.
[0130] Further, based on the above first embodiment, a second embodiment of the blockchain service transaction execution method of the present invention is proposed. In this embodiment, the step of calculating the parallelism according to the device information of each consensus node recorded in the smart contract in step S40 includes:
[0131] Step S401, calculating the performance index value of the i-th consensus node according to the device information of the i-th consensus node recorded in the smart contract;
[0132] Considering that there may be consensus nodes that crash due to failures or are attacked among the consensus nodes of the consortium blockchain, in order to ensure that the joint calculation of the parallelism can be completed in the case of some consensus nodes crashing or being attacked, in this embodiment, a parallelism calculation method is proposed.
[0133] Specifically, after the consensus node records the device information of each consensus node in the smart contract, it can calculate the performance index value of the i-th consensus node according to the device information of the i-th consensus node recorded in the smart contract. Among them, the performance index value can be one or more. For example, the number of CPUs can be used as the performance index value, and it is not specifically limited in this embodiment.
[0134] Step S402, after sorting the performance index values of each consensus node in descending order, select the minimum performance index value among the first n - f performance index values, where n is the number of consensus nodes in the consortium blockchain, and 3f + 1 = n;
[0135] After the consensus node calculates the performance index values of each consensus node, it can sort the performance index values of each consensus node in descending order and select the minimum performance index value (hereinafter referred to as the minimum performance index value) among the first n - f ("-" represents the minus sign) performance index values. n is the number of consensus nodes in the consortium blockchain, and f is the number of crashed nodes that can be tolerated. According to the principle of the Byzantine consensus algorithm, 3f + 1 = n.
[0136] Step S403, calculating the parallelism according to the minimum performance index value.
[0137] The consensus node can calculate the parallelism according to the selected minimum performance index value. Specifically, the specific method of calculating the parallelism according to the minimum performance index value is not limited in this embodiment. For example, in one embodiment, if the minimum performance index value is the number of CPUs, then the consensus node can directly use this minimum performance index value as the parallelism.
[0138] By sorting the performance metric values of each consensus node in descending order and selecting the smallest performance metric value among the top n - f performance metric values, the parallelism is calculated based on the assumption that f consensus nodes are down. When no more than f consensus nodes are down, a consistent parallelism can still be calculated.
[0139] Further, in one embodiment, step S401 includes:
[0140] Step S4011, multiply the number of CPUs and the CPU frequency of the i-th consensus node recorded in the smart contract to obtain the first performance metric value of the i-th consensus node;
[0141] Step S4012, take the number of CPUs of the i-th consensus node recorded in the smart contract as the second performance metric value of the i-th consensus node;
[0142] Since the number of CPUs and the CPU frequency of each consensus node device jointly determine the computing performance of the node, in this embodiment, to further improve the rationality of parallelism calculation, the device information of the i-th consensus node may include the number of CPUs and the CPU frequency of the i-th consensus node. That is, the consensus node can collect the number of CPUs and the CPU frequency of its own node and submit them as information reporting transactions.
[0143] When calculating the performance metric value of the i-th consensus node, two performance metric values can be calculated. Specifically, the consensus node can multiply the number of CPUs and the CPU frequency of the i-th consensus node recorded in the smart contract to obtain a performance metric value of the i-th consensus node (hereinafter referred to as the first performance metric value for distinction). The consensus node also takes the number of CPUs of the i-th consensus node recorded in the smart contract as another performance metric value of the i-th consensus node (hereinafter referred to as the second performance metric value for distinction). That is, two performance metric values corresponding to each consensus node are calculated.
[0144] Step S402 includes:
[0145] Step S4021, after sorting the first performance metric values of each consensus node in descending order, select the smallest first performance metric value among the top n - f first performance metric values;
[0146] Step S4022, after sorting the second performance metric values of each consensus node in descending order, select the smallest second performance metric value among the top n - f second performance metric values;
[0147] After calculating the first performance metric values of each consensus node, the consensus node can sort the first performance metric values in descending order, and then select the smallest first performance metric value among the top n - f first performance metric values (hereinafter referred to as the smallest first performance metric value). After calculating the second performance metric values of each consensus node, the consensus node can sort the second performance metric values in descending order, and then select the smallest second performance metric value among the top n - f second performance metric values (hereinafter referred to as the smallest second performance metric value).
[0148] Step S403 includes:
[0149] Step S4031, dividing the smallest first performance metric value by the smallest second performance metric value and then rounding to obtain the parallelism degree.
[0150] After calculating the smallest first performance metric value and the smallest second performance metric value, the consensus node can divide the smallest first performance metric value by the smallest second performance metric value and then round, and use the result as the parallelism degree. For example, using Zmin to represent the smallest first performance metric value and CPUmin to represent the smallest second performance metric value, then the parallelism degree P = round(Zmin / CPUmin).
[0151] The parallelism degree calculated by the method of this embodiment is a reasonable parallelism degree calculated by comprehensively considering the resource conditions of each consensus node device. On the one hand, it can improve the performance of blockchain transaction execution, and on the other hand, it can also save storage space.
[0152] For example, taking the scenario of transferring 1W to 1 account and a consortium chain with 4 consensus nodes as an example, the machine configuration and testing are carried out according to the data in the following
[0153] Table 1 for testing:[[]]END]]
[0154]
[0155]
[0156] Table 1
[0157] The test results and transaction performance comparison data are as follows in Table 2:[[]]END]]
[0158]
[0159] Table 2
[0160] It can be known from Table 2 that the parallel scheme is better than the non - parallel scheme, and the highly parallel scheme has lower transaction execution performance than the transaction execution performance of the scheme of this embodiment of the invention because there are many more thread switches.
[0161] The comparison data of storage performance is shown in Table 3 below:
[0162]
[0163] Table 3
[0164] According to the above calculation formula of parallelism P = round(Zmin / CPUmin), the parallelism can be calculated to be 6. It can be seen from the data in Table 3 that in terms of storage performance, the storage performance without parallelism is the highest, the solution of the embodiment of the present invention is the second, and the highly parallel one is the worst.
[0165] Further, based on the above first and / or second embodiments, a third embodiment of the method for executing blockchain business transactions of the present invention is proposed. In this embodiment, the step S50 includes:
[0166] Step S501: Divide each business transaction in the target block to obtain a plurality of transaction sets, where at least one business transaction is included in one transaction set, and the number of transaction sets is the same as the parallelism recorded in the smart contract;
[0167] In this embodiment, when a consensus node executes the business transactions in the target block, specifically, it can first divide each business transaction in the target block to obtain a plurality of transaction sets. At least one business transaction is included in one transaction set, and the number of transaction sets is the same as the parallelism recorded in the smart contract. Among them, the method of dividing business transactions into transaction sets is not specifically limited in this embodiment.
[0168] In some implementation manners, when it is necessary to ensure that the transaction sets obtained by each consensus node are the same, a division method can be preset so that the transaction sets obtained by each consensus node for dividing the business transactions in the target block are the same. For example, in one implementation manner, the number of business transactions in the target block can be divided by the parallelism in the smart contract and rounded up to obtain the number of transactions in each transaction set, and each business transaction arranged in order in the target block can be divided into a plurality of transaction sets according to this number of transactions. It can be understood that the transaction sets obtained by each consensus node according to this method are the same. Another example, in another implementation manner, the index of the business transactions in the target block can be modulo the parallelism in the smart contract, and the transactions with the same modulo result are divided into one transaction set. It can be understood that the transaction sets obtained by each consensus node according to this method are also the same.
[0169] Step S502: Start a thread for each of the transaction sets, and execute the corresponding transaction set in parallel through each thread, where each thread executes each business transaction in the corresponding transaction set in a serial manner.
[0170] Start a thread for each transaction set. That is, if there are m transaction sets, start m threads. Execute the corresponding transaction sets in parallel through each thread. That is, the j-th thread executes the j-th transaction set, and the m threads are executed in parallel. Each thread executes each business transaction in the corresponding transaction set in a serial manner. That is, the j-th thread serially executes each business transaction in the j-th transaction set.
[0171] Further, in one embodiment, the step S501 includes:
[0172] Step S5011, for any target business transaction in the target block, take the modulus of the index of the target business transaction in the target block with the parallelism recorded in the smart contract to obtain a modulus result;
[0173] In the scenario of multi-to-one transfer, when the receiving accounts of all business transactions in the target block are the same account, the receiving accounts of all business transactions can be distinguished by adding receiving accounts, so as to construct conflict-free transactions and avoid conflicts during parallel execution.
[0174] Specifically, for any one business transaction in the target block (hereinafter referred to as the target business transaction for distinction), the consensus node can take the modulus of the index of the target business transaction in the target block with the parallelism recorded in the smart contract, and the obtained result is called the modulus result.
[0175] Step S5012, determine the target sub-account number corresponding to the target business transaction according to the modulus result, so as to use the transfer sub-account corresponding to the target sub-account number as the receiving account when executing the target business transaction;
[0176] The consensus node determines the sub-account number corresponding to the target business transaction according to the modulus result (hereinafter referred to as the target sub-account number). Among them, multiple transfer sub-accounts can be set in the smart contract in advance for use as receiving accounts, and each transfer sub-account can be numbered to distinguish each sub-account. It should be noted that since the smart contracts of each consensus node are the same, the transfer sub-accounts and the corresponding numbers set in the smart contracts of each consensus node are also the same.
[0177] When the numbers of all transfer sub-accounts start from 0, the consensus node can directly use the modulus result as the target sub-account number; when the numbers of all transfer sub-accounts start from 1, the consensus node can use the modulus result plus 1 as the target sub-account number. That is, according to the different numbering methods of each transfer sub-account, the method of determining the target sub-account number based on the modulus result is also different.
[0178] The purpose of the consensus node to determine the target sub-account number corresponding to the target business transaction is to use the transfer sub-account corresponding to the target sub-account number as the receiving account of the target business transaction when executing the target business transaction, so as to distinguish the receiving accounts of the transactions that need to be executed in parallel and avoid conflicts during transaction execution.
[0179] Step S5013: Construct each business transaction corresponding to the same sub-account number into a transaction set.
[0180] After the consensus node determines the sub-account numbers corresponding to each business transaction in the target block, it can construct each business transaction corresponding to the same sub-account number into a transaction set. That is, each business transaction corresponding to the same sub-account number needs to be executed serially, and business transactions corresponding to different sub-account numbers can be executed in parallel.
[0181] Furthermore, in one implementation, the steps of executing the target business transaction include:
[0182] Step a: Detect whether the transfer sub-account corresponding to the target sub-account number exists through the smart contract;
[0183] When the consensus node executes each business transaction in the target block, it can first determine whether the corresponding transfer sub-account exists through the smart contract. If it does not exist, it can be dynamically created.
[0184] Specifically, taking one of the business transactions (the target business transaction) as an example for illustration. The consensus node can first detect whether the transfer sub-account corresponding to the target sub-account number of the target business transaction exists through the smart contract, that is, determine whether there is a transfer sub-account corresponding to this number. For example, five transfer sub-accounts with numbers 0-4 are pre-created in the consensus node smart contract, and the parallelism is 6. Suppose the index of the target business transaction modulo 6 is 5, that is, the target sub-account number is 5. Then when the consensus node detects whether the transfer sub-account corresponding to the target sub-account number exists, it detects that there is no transfer sub-account with the number 5, so it determines that the transfer sub-account corresponding to the target sub-account number does not exist.
[0185] Step b: If it exists, use the transfer sub-account corresponding to the target sub-account number as the receiving account of the target business transaction to execute the transaction;
[0186] If it is detected that the transfer sub-account corresponding to the target sub-account number exists, the consensus node can directly use this transfer sub-account as the receiving account of the target business transaction to execute the transaction.
[0187] Step c, if not, create a transfer sub-account through the smart contract as the transfer sub-account corresponding to the target sub-account number, and use the transfer sub-account corresponding to the target sub-account number as the receiving account for the target business transaction to execute the transaction.
[0188] If it is detected that the transfer sub-account corresponding to the target sub-account number does not exist, the consensus node can create a transfer sub-account through the smart contract, and use the newly created transfer sub-account as the receiving account for the target business transaction to execute the transaction. It should be noted that the smart contracts of each consensus node are the same, so the transfer sub-accounts created by each consensus node through the smart contract are also the same, thus ensuring that the execution results of each business transaction in the target block by each consensus node are consistent.
[0189] In addition, an embodiment of the present invention further proposes a blockchain business transaction execution device. Referring to Figure 4 , the device is deployed on the consensus node in the consortium blockchain, and the device includes:
[0190] An information collection module 10, configured to collect the first device information of the local node and report the first device information as the first information to the transaction submission;
[0191] A contract module 20, configured to record the first device information in the smart contract according to the reported first information transaction and broadcast the reported first information transaction to other consensus nodes in the consortium blockchain;
[0192] The contract module 20 is further configured to receive the second information reported transactions broadcast by other consensus nodes, and record the second device information of other consensus nodes in the second information reported transaction in the smart contract;
[0193] The contract module 20 is further configured to calculate the parallelism according to the device information of each consensus node recorded in the smart contract, and record the parallelism in the smart contract;
[0194] A parallel execution module 30, configured to start multiple threads to execute each business transaction in the target block in parallel according to the parallelism recorded in the smart contract when executing the business transaction in the target block.
[0195] Further, the contract module 20 is further configured to:
[0196] Calculate the performance index value of the i-th consensus node according to the device information of the i-th consensus node recorded in the smart contract;
[0197] After sorting the performance metric values of each consensus node in descending order, select the minimum performance metric value among the top n - f performance metric values, where n is the number of consensus nodes in the consortium blockchain and 3f + 1 = n;
[0198] Calculate the parallelism based on the minimum performance metric value.
[0199] Furthermore, the device information of the i-th consensus node includes the number of CPUs and the CPU frequency of the i-th consensus node;
[0200] The contract module 20 is further configured to:
[0201] Multiply the number of CPUs and the CPU frequency of the i-th consensus node recorded in the smart contract to obtain the first performance metric value of the i-th consensus node;
[0202] Take the number of CPUs of the i-th consensus node recorded in the smart contract as the second performance metric value of the i-th consensus node;
[0203] After sorting the first performance metric values of each consensus node in descending order, select the minimum first performance metric value among the top n - f first performance metric values;
[0204] After sorting the second performance metric values of each consensus node in descending order, select the minimum second performance metric value among the top n - f second performance metric values;
[0205] Round the result of dividing the minimum first performance metric value by the minimum second performance metric value to obtain the parallelism.
[0206] Furthermore, the parallel execution module 30 is further configured to:
[0207] Divide the various business transactions in the target block to obtain multiple transaction sets, where at least one business transaction is included in one transaction set, and the number of transaction sets is the same as the parallelism recorded in the smart contract;
[0208] Start a thread for each of the transaction sets, and parallelly execute the corresponding transaction set through each thread, where each thread executes the various business transactions in the corresponding transaction set in a serial manner.
[0209] Furthermore, the parallel execution module 30 is further configured to:
[0210] For any target business transaction in the target block, take the modulus of the index of the target business transaction in the target block by the parallelism recorded in the smart contract to obtain the modulus result;
[0211] Determine the target sub-account number corresponding to the target business transaction according to the modulo result, so as to use the transfer sub-account corresponding to the target sub-account number as the receiving account of the target business transaction when executing the target business transaction;
[0212] Construct each business transaction corresponding to the same sub-account number into a transaction set.
[0213] Furthermore, the parallel execution module 30 is further configured to:
[0214] Detect whether the transfer sub-account corresponding to the target sub-account number exists through the smart contract;
[0215] If it exists, use the transfer sub-account corresponding to the target sub-account number as the receiving account of the target business transaction to execute the transaction;
[0216] If it does not exist, create a transfer sub-account as the transfer sub-account corresponding to the target sub-account number through the smart contract, and use the transfer sub-account corresponding to the target sub-account number as the receiving account of the target business transaction to execute the transaction.
[0217] Furthermore, the contract module 20 is further configured to:
[0218] Sign the first information reporting transaction with the private key of this node, and broadcast the signed first information reporting transaction to other consensus nodes in the consortium chain;
[0219] The step of recording the second device information of other consensus nodes in the second information reporting transaction in the smart contract includes:
[0220] Verify the signature of the signed second information reporting transaction with the public keys of other consensus nodes, and record the second device information of other consensus nodes in the second information reporting transaction in the smart contract when the signature verification is passed.
[0221] The expansion content of the specific implementation manner of the blockchain business transaction execution of the present invention is basically the same as that of the above-mentioned embodiments of the blockchain business transaction execution, and will not be elaborated here.
[0222] In addition, an embodiment of the present invention also proposes a computer-readable storage medium, on which a blockchain business transaction execution program is stored. When the blockchain business transaction execution program is executed by a processor, the steps of the blockchain business transaction execution method described in the above embodiments are implemented.
[0223] For each embodiment of the blockchain business transaction execution device and the computer-readable storage medium of the present invention, reference can be made to each embodiment of the blockchain business transaction execution method of the present invention, which will not be elaborated here.
[0224] It should be noted that, in this article, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or further includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including one..." does not exclude the existence of additional identical elements in the process, method, article or device including such element.
[0225] The serial numbers of the embodiments of the present invention above are only for description and do not represent the superiority or inferiority of the embodiments.
[0226] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-described embodiment methods can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disc) and includes several instructions for causing a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0227] The above are only the preferred embodiments of the present invention and do not limit the patent scope of the present invention accordingly. Any equivalent structure or equivalent process transformation made by using the content of the specification and drawings of the present invention, or directly or indirectly applied in other related technical fields, shall be equally included in the patent protection scope of the present invention.
Claims
1. A method for executing blockchain business transactions, characterized in that, The method is applied to consensus nodes in a consortium blockchain, and the method includes the following steps: Collect the first device information of the local node and report the first device information as the first information for transaction submission; Record the first device information in the smart contract according to the submitted first information for transaction reporting, and broadcast the first information for transaction reporting to other consensus nodes in the consortium blockchain; Receive the second information for transaction reporting broadcast by other consensus nodes, and record the second device information of other consensus nodes in the second information for transaction reporting in the smart contract; Calculate the performance metric value of the i-th consensus node according to the device information of the i-th consensus node recorded in the smart contract; After sorting the performance metric values of each consensus node from largest to smallest, select the smallest performance metric value among the first n - f performance metric values, where n is the number of consensus nodes in the consortium blockchain, f is the number of downtime nodes that can be tolerated, and 3f + 1 = n; Calculate the parallelism according to the smallest performance metric value and record the parallelism in the smart contract; When executing the business transactions in the target block, start multiple threads to execute each business transaction in the target block in parallel according to the parallelism recorded in the smart contract.
2. The blockchain business transaction execution method according to claim 1, wherein, The device information of the i-th consensus node includes the number of CPUs and the CPU frequency of the i-th consensus node; The step of calculating the performance metric value of the i-th consensus node according to the device information of the i-th consensus node recorded in the smart contract includes: Multiply the number of CPUs and the CPU frequency of the i-th consensus node recorded in the smart contract to obtain the first performance metric value of the i-th consensus node; Take the number of CPUs of the i-th consensus node recorded in the smart contract as the second performance metric value of the i-th consensus node; The step of selecting the smallest performance metric value among the first n - f performance metric values after sorting the performance metric values of each consensus node from largest to smallest includes: Sort the first performance metric values of each consensus node from largest to smallest, and select the smallest first performance metric value among the first n - f first performance metric values; Sort the second performance metric values of each consensus node from largest to smallest, and select the smallest second performance metric value among the first n - f second performance metric values; The step of calculating the parallelism according to the smallest performance metric value includes: Divide the smallest first performance metric value by the smallest second performance metric value and round the result to obtain the parallelism.
3. The blockchain business transaction execution method according to claim 1, wherein The step of starting multiple threads to execute each business transaction in the target block in parallel according to the parallelism recorded in the smart contract includes: Divide each business transaction in the target block to obtain multiple transaction sets, where each transaction set contains at least one business transaction, and the number of transaction sets is the same as the parallelism recorded in the smart contract; Start a thread for each of the said transaction sets, and execute the corresponding transaction set in parallel through each of the said threads. Among them, each of the said threads executes each business transaction in the corresponding transaction set in a serial manner.
4. The blockchain business transaction execution method according to claim 3, wherein The step of dividing each business transaction in the target block to obtain multiple transaction sets includes: For any target business transaction in the target block, take the modulus of the index of the target business transaction in the target block with respect to the parallelism recorded in the smart contract to obtain a modulus result; Determine the target sub-account number corresponding to the target business transaction according to the modulus result, so as to use the transfer sub-account corresponding to the target sub-account number as the receiving account of the target business transaction when executing the target business transaction; Construct each business transaction corresponding to the same sub-account number into a transaction set.
5. The blockchain business transaction execution method according to claim 4, wherein The step of executing the target business transaction includes: Detect whether the transfer sub-account corresponding to the target sub-account number exists through the smart contract; If it exists, use the transfer sub-account corresponding to the target sub-account number as the receiving account of the target business transaction to execute the transaction; If it does not exist, create a transfer sub-account through the smart contract as the transfer sub-account corresponding to the target sub-account number, and use the transfer sub-account corresponding to the target sub-account number as the receiving account of the target business transaction to execute the transaction.
6. The blockchain business transaction execution method according to any one of claims 1 to 5, characterized in that, The step of broadcasting the first information reporting transaction to other consensus nodes in the consortium blockchain includes: Sign the first information reporting transaction with the private key of this node, and broadcast the signed first information reporting transaction to other consensus nodes in the consortium blockchain; The step of recording the second device information of other consensus nodes in the second information reporting transaction in the smart contract includes: Verify the signature of the signed second information reporting transaction with the public keys of other consensus nodes, and record the second device information of other consensus nodes in the second information reporting transaction in the smart contract when the signature verification is passed.
7. A blockchain business transaction execution device, characterized in that, The device is deployed in a consensus node in the consortium blockchain, and the device includes: An information collection module, configured to collect the first device information of this node and submit the first device information as a first information reporting transaction; A contract module, configured to record the first device information in the smart contract according to the submitted first information reporting transaction, and broadcast the first information reporting transaction to other consensus nodes in the consortium blockchain; The contract module is further configured to receive the second information reporting transactions broadcast by other consensus nodes, and record the second device information of other consensus nodes in the second information reporting transactions in the smart contract; The contract module is further configured to calculate the performance metric value of the i-th consensus node according to the device information of the i-th consensus node recorded in the smart contract; after sorting the performance metric values of each consensus node in descending order, select the smallest performance metric value among the first n-f performance metric values, where n is the number of consensus nodes in the consortium chain, f is the number of downtime nodes that can be tolerated, and 3f + 1 = n; calculate the parallelism according to the smallest performance metric value, and record the parallelism in the smart contract; The parallel execution module is configured to, when executing the business transactions in the target block, start multiple threads to execute each business transaction in the target block in parallel according to the parallelism recorded in the smart contract.
8. A blockchain business transaction execution device, characterized in that, The blockchain business transaction execution device includes: a memory, a processor, and a blockchain business transaction execution program stored on the memory and executable on the processor. When the blockchain business transaction execution program is executed by the processor, the steps of the blockchain business transaction execution method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium, characterized in that, A blockchain business transaction execution program is stored on the computer-readable storage medium. When the blockchain business transaction execution program is executed by the processor, the steps of the blockchain business transaction execution method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Data processing method and device based on block chain
CN110489420A