Blockchain contract scheduling method, device and system

Through the blockchain contract scheduling method, the transaction process is dynamically scheduled according to the parallel status of the transaction contract, which solves the problems of high concurrency and frequent retransmission of account-type transactions in the existing technology and improves the overall performance and reliability of the blockchain system.

CN115983990BActive Publication Date: 2025-10-10INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211477789.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-23
Publication Date
2025-10-10
Estimated Expiration
2042-11-23

AI Technical Summary

Technical Problem

Existing blockchain systems have problems with high concurrency and high failure rate when processing account transactions. In application scenarios where the ledger status changes frequently, transactions need to be resent frequently, affecting performance.

Method used

Through the blockchain contract scheduling method, the transaction process is dynamically scheduled according to the parallel status of the transaction contract. The transaction is first packaged into blocks for consensus, and then sent to the pre-selected accounting nodes for execution and update the blockchain ledger according to the parallel status. Random number generation is used when selecting the accounting nodes to ensure security and reliability.

Benefits of technology

It improves the overall performance of the blockchain system, reduces transaction failure rates, improves the system's operating efficiency and reliability, and dynamically schedules contract execution to meet the needs of different types of transactions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115983990B_ABST
    Figure CN115983990B_ABST
Patent Text Reader

Abstract

The application provides a blockchain contract scheduling method, device and system, which can be applied to the technical field of blockchains. The blockchain contract scheduling method is applied to a consensus node, the consensus node and a ledger node constitute a blockchain network; the blockchain contract scheduling method comprises the following steps: obtaining a transaction contract according to a transaction in a transaction request from a client, and performing consensus after the transaction is packaged into a block; broadcasting the block to all ledger nodes, so that all the ledger nodes write the block into a blockchain ledger; and sending the transaction to a preselected ledger node according to a parallel state of the transaction contract, so that the ledger node updates the blockchain ledger written by the block according to a transaction result after executing the transaction. The application can realize dynamic scheduling of a transaction process, thereby improving the overall performance of the system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of blockchain technology, and in particular to a blockchain contract scheduling method, device, and system. Background Art

[0002] 1. Technical solutions of existing technologies

[0003] There are currently two mainstream consortium blockchain architectures in the industry. One is based on a "consensus-contract execution-submission" transaction process. When a blockchain node receives a transaction, it first packages the transaction and broadcasts it to all nodes through a consensus algorithm. Each node then calls the contract to execute the packaged transaction in turn and updates the ledger based on the execution results.

[0004] The other is a transaction process based on "endorsement-consensus-verification-submission." When a client receives a transaction, it first submits it to a specific organization node based on the endorsement policy. The receiving node simulates contract execution based on the current ledger snapshot, signs and endorses the execution results, and returns them to the client. After the client receives responses from all endorsement requests, it packages all endorsement results and submits them to the sorting node for block sorting. Once the block is generated, it is broadcast to all organization nodes, which verify the endorsement signature and endorsement policy before writing it to the ledger.

[0005] 2. Disadvantages of existing technologies

[0006] For blockchain systems that adopt a "consensus-contract execution-submission" architecture, since contract execution occurs after consensus, smart contracts must be executed on all nodes with the same ledger. These contracts must be installed and packaged in a strict order, executed, and submitted to the ledger. This requires deploying contracts on all nodes, resulting in significant overall performance overhead. Furthermore, the serial execution of contracts and the nature of this architecture make it difficult to scale the system's operational efficiency. Furthermore, since consensus covers the transaction itself and not the transaction results, the transaction results that need to be uploaded to the blockchain must be obtained by executing smart contracts. Consequently, ledger consistency relies on the consistent execution results of each contract. In practical application, ledger forks caused by abnormal contract execution are more likely to occur, creating certain difficulties for system operation and maintenance.

[0007] Blockchain systems that adopt an "endorsement-consensus-verification-commit" architecture mitigate some of the drawbacks of the "consensus-contract execution-commit" architecture by preempting contract execution before consensus. For example, clients only need to submit transactions to specific nodes based on endorsement policies for smart contract execution, so contracts only need to be deployed on a subset of an organization's nodes, not all. Furthermore, by decoupling contract execution from consensus, transactions can be parallelized by horizontally scaling the number of nodes deploying contracts, thereby improving system performance. Furthermore, because consensus includes transaction results and the final ledger submission is performed through a series of atomic operations, ledger data consistency is highly guaranteed. This architecture can fully leverage its performance advantages in applications where ledger state is frequently updated (such as evidence storage transactions), allowing for parallel execution. However, applications where ledger state frequently changes (such as account transactions) are sequence-dependent and cannot be executed in parallel. In contrast, this architecture results in a higher failure rate with higher concurrency, leading to frequent transaction retransmissions and performance degradation. This is because contract execution is based on the current state of the node's ledger. Since the transaction process follows the "endorsement-consensus-verification submission" model, there may be some in-progress transactions that have submitted to consensus but haven't yet completed verification and submission. When the transaction is finally submitted for verification and submission, the previous in-progress transactions have already changed the previous ledger state, causing the transaction to fail verification. Therefore, for account-based transactions, the "consensus-contract execution-submission" architecture is more advantageous. Summary of the Invention

[0008] The main purpose of the embodiments of the present invention is to provide a blockchain contract scheduling method, device and system to dynamically schedule transaction processes based on the parallel status of transaction contracts, thereby improving the overall performance of the system.

[0009] To achieve the above objectives, an embodiment of the present invention provides a blockchain contract scheduling method. The blockchain contract scheduling method is applied to consensus nodes. Consensus nodes and accounting nodes constitute a blockchain network. The blockchain contract scheduling method includes:

[0010] Obtain the transaction contract based on the transaction in the transaction request from the client, package the transaction into blocks, and then conduct consensus;

[0011] Broadcast the block to all accounting nodes so that all accounting nodes write the block into the blockchain ledger;

[0012] The transaction is sent to a pre-selected accounting node based on the parallel state of the transaction contract, so that the accounting node can update the blockchain ledger written into the block according to the transaction result after executing the transaction.

[0013] In one embodiment, sending the transaction to the selected accounting node according to the parallel status of the transaction contract includes:

[0014] When the parallel state of the transaction contract is parallel, the transaction is sent to the selected accounting node.

[0015] In one embodiment, it further includes:

[0016] When the parallel status of the transaction contract is parallel, mark the transaction;

[0017] When the parallel state of the transaction contract is non-parallel, the block is broadcast to all accounting nodes so that all accounting nodes execute the unmarked transaction and update the blockchain ledger according to the transaction results.

[0018] In one embodiment, it further includes:

[0019] Receive historical transaction results including status key values ​​from the accounting node and put the historical transaction results into the corresponding contract cache queue;

[0020] The parallel status of the transaction contract is determined based on the number of historical transaction results and the number of each state key value in the contract cache queue.

[0021] In one embodiment, preselecting a billing node includes:

[0022] Generate a random number based on the hash value of the latest block to select a ledger node in the ledger node routing table.

[0023] An embodiment of the present invention further provides a blockchain contract scheduling device, which is applied to consensus nodes. The consensus nodes and accounting nodes constitute a blockchain network. The blockchain contract scheduling device includes:

[0024] The packaging module is used to obtain the transaction contract based on the transaction in the transaction request from the client, package the transaction into blocks, and then conduct consensus;

[0025] A broadcast module, used to broadcast the block to all accounting nodes so that all accounting nodes write the block into the blockchain ledger;

[0026] The sending module is used to send the transaction to the pre-selected accounting node according to the parallel state of the transaction contract, so that the accounting node can update the blockchain ledger written into the block according to the transaction result after executing the transaction.

[0027] In one embodiment, the sending module is specifically configured to:

[0028] When the parallel state of the transaction contract is parallel, the transaction is sent to the selected accounting node.

[0029] In one embodiment, it further includes:

[0030] The marking module is used to mark the transaction when the parallel status of the transaction contract is parallel;

[0031] The broadcast module is specifically used to: when the parallel state of the transaction contract is non-parallel, broadcast the block to all accounting nodes, so that all accounting nodes execute unmarked transactions and update the blockchain ledger according to the transaction results.

[0032] In one embodiment, it further includes:

[0033] The cache queue insertion module is used to receive historical transaction results including status key values ​​from the accounting node and put the historical transaction results into the corresponding contract cache queue;

[0034] The parallel state module is used to determine the parallel state of the transaction contract based on the number of historical transaction results and the number of each state key value in the contract cache queue.

[0035] In one embodiment, it further includes:

[0036] The accounting node selection module is used to generate a random number based on the hash value of the latest block to select an accounting node in the accounting node routing table.

[0037] An embodiment of the present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, the steps of the blockchain contract scheduling method are implemented.

[0038] An embodiment of the present invention also provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of the blockchain contract scheduling method when the computer program is executed by a processor.

[0039] An embodiment of the present invention also provides a computer program product, including a computer program / instruction, which implements the steps of the blockchain contract scheduling method when the computer program / instruction is executed by a processor.

[0040] An embodiment of the present invention further provides a blockchain contract scheduling system, comprising:

[0041] Clients, consensus nodes, and accounting nodes; consensus nodes and accounting nodes constitute the blockchain network;

[0042] The consensus node obtains the transaction contract based on the transaction in the transaction request from the client, packages the transaction into a block, performs consensus, and broadcasts the block to all accounting nodes; based on the parallel status of the transaction contract, the transaction is sent to the pre-selected accounting node;

[0043] The accounting node writes the block into the blockchain ledger; after the transaction is executed, the blockchain ledger where the block was written is updated according to the transaction results.

[0044] The blockchain contract scheduling method, device and system of the embodiments of the present invention first package transactions into blocks and then reach consensus, then broadcast the blocks to all accounting nodes for writing into the blockchain ledger, and finally send the transactions to pre-selected accounting nodes based on the parallel status of the transaction contract, so that the accounting nodes can update the blockchain ledger written into the blocks according to the transaction results after executing the transactions. This can realize dynamic scheduling of the transaction process and thus improve the overall performance of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0046] Figure 1 This is a flowchart of a blockchain contract scheduling method according to an embodiment of the present invention;

[0047] Figure 2 is a flowchart of a blockchain contract scheduling method in another embodiment of the present invention;

[0048] Figure 3 is a flow chart for determining a parallel state in an embodiment of the present invention;

[0049] Figure 4 This is a flowchart of selecting an accounting node in an embodiment of the present invention;

[0050] Figure 5 This is a structural block diagram of a blockchain contract scheduling device according to an embodiment of the present invention;

[0051] Figure 6 This is a structural block diagram of a blockchain contract scheduling device, a client, and an accounting node in another embodiment of the present invention;

[0052] Figure 7 is a structural block diagram of a computer device according to an embodiment of the present invention;

[0053] Figure 8 Schematic diagram of a blockchain contract scheduling system in an embodiment of the present invention. DETAILED DESCRIPTION

[0054] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0055] Those skilled in the art understand that the embodiments of the present application can be implemented as a system, device, apparatus, method or computer program product. Therefore, the present disclosure can be embodied in the form of a complete hardware, complete software (including firmware, resident software, microcode, etc.), or a combination of hardware and software.

[0056] The acquisition, storage, use, processing and the like of data in the technical solutions of the present application comply with the relevant provisions of national laws and regulations.

[0057] In view of the problems of operation and maintenance difficulty and low performance of the current blockchain system, the embodiments of the present application provide a blockchain contract scheduling method, device and system, which statistically judges whether the contract is parallel by reading and writing information of the contract ledger state, and dynamically schedules the transaction process in the process of processing transactions according to the judgment result, thereby improving the overall performance of the system. The present application will be described in detail below with reference to the accompanying drawings.

[0058] Figure 1 is a flowchart of the blockchain contract scheduling method in the embodiments of the present application. Figure 2 is a flowchart of the blockchain contract scheduling method in another embodiment of the present application. As shown in Figure 1-Figure 2 , the blockchain contract scheduling method is applied to a consensus node, and the consensus node and a ledger node constitute a blockchain network; the blockchain contract scheduling method comprises:

[0059] S101: obtaining a transaction contract according to a transaction in a transaction request from a client, and performing consensus after packing the transaction into a block.

[0060] In specific implementation, as shown in Figure 2 , the client initiates a transaction request to any consensus node, and the consensus node verifies the transaction legality through a data preprocessing module and obtains the contract name called by the transaction, and packs the transaction into a block according to the packing rule (time interval, transaction quantity, etc.) and performs consensus on the block among multiple consensus nodes.

[0061] S102: broadcasting the block to all ledger nodes, so that all ledger nodes write the block into a blockchain ledger.

[0062] S103: sending the transaction to the preselected ledger node according to the parallel state of the transaction contract, so that the ledger node updates the blockchain ledger written in the block according to the transaction result after executing the transaction.

[0063] Among them, the ledger node first verifies the legality of the data after receiving the block, transaction or transaction result.

[0064] When the accounting node receives a transaction, it calls the smart contract to execute the transaction and caches the transaction result, and broadcasts the transaction result to other accounting nodes.

[0065] When the accounting node receives the transaction result, it queries whether the block where the transaction result is located has been written into the blockchain ledger. If not, the transaction result is saved in the transaction result cache waiting for block writing; if yes, the world state of the blockchain ledger is updated according to the transaction result, and the transaction result is deleted in the transaction result cache.

[0066] The accounting node will clean up the transaction result cache stored for a long time. To avoid data loss caused by the misdeletion of the transaction result, the accounting node will detect the transaction that has been blocked but has not been updated for a long time, and synchronize the execution result of the transaction through other nodes.

[0067] When the read-write set verification of updating the world state of the blockchain ledger fails, the accounting node returns the update failure result to the consensus node, and the consensus node notifies all accounting nodes to re-execute the contract from the position of the update failure. The accounting node re-executes the failed transaction according to the block order from the position of the verification failure, and updates the world state of the blockchain ledger according to the execution result again, and returns the ledger update failure message to the consensus node; if the update is successful, the process ends.

[0068] Figure 3 is a flowchart for determining parallel state in an embodiment of the application. As shown in Figure 3 The blockchain contract scheduling method further comprises:

[0069] 1. Receive the historical transaction result including the state key value from the accounting node, and put the historical transaction result into the corresponding contract cache queue.

[0070] The accounting node will send the historical transaction result to the designated consensus node. The consensus node puts the historical transaction result into the corresponding contract cache queue according to the contract name, and does not need to update if the result has been cached. If the consensus node receives the ledger update failure message sent by the accounting node, it will mark the contract as non-parallel, clear the execution result cache queue of the contract, and notify the client to resend the transaction.

[0071] 2. Determine the parallel state of the transaction contract according to the number of historical transaction results in the contract cache queue and the number of state key values.

[0072] In practice, consensus nodes accumulate the number of each state key value in the transaction read and write values. If the read and write counts for each state key value for a contract are both 1, and the number of historical transaction results in the contract cache queue exceeds a configurable minimum threshold, the contract is marked as parallelizable. Otherwise, the contract is marked as non-parallelizable. The updated contract parallel status is synchronized across all consensus nodes.

[0073] The consensus node will periodically clean up the cache. If the contract cache queue length exceeds the minimum threshold, data that has been stored for longer than the preset time (configurable) will be deleted.

[0074] Figure 4 This is a flowchart of selecting accounting nodes in an embodiment of the present invention. Figure 4 As shown, the pre-selected accounting nodes include:

[0075] Generate a random number based on the hash value of the latest block to select a ledger node in the ledger node routing table.

[0076] In practice, upon startup, a ledger node sends a registration message to a consensus node. The consensus node verifies the legitimacy of the registration message and, upon successful verification, adds it to the ledger node's routing table. When a consensus node receives a transaction that can be processed in parallel, it generates a verifiable random number based on the hash value of the latest block and modulo the node's routing table to select the ledger node to execute the transaction. If multiple ledger nodes are required to execute the transaction, the number of remaining nodes is further moduloed until all nodes have been selected, and the transaction is then sent to the randomly selected ledger node. When the consensus node packages the transaction into a block, it includes the aforementioned hash value, block height, and random number. When verifying the transaction results in the block, the ledger node verifies the random number against the verification information included with the transaction in the block. It also verifies that the signature in the transaction result matches the ledger node selected by the random number. Only after successful verification can the subsequent processes be executed.

[0077] When the accounting node executes a transaction, it will sign the transaction and attach it to the transaction result message.

[0078] In one embodiment, sending the transaction to the selected accounting node based on the parallel status of the transaction contract includes:

[0079] When the parallel state of the transaction contract is parallel, the transaction is marked as pre-execution and sent to the selected accounting node.

[0080] Blockchain contract scheduling methods also include:

[0081] When the parallel state of the transaction contract is non-parallel, the block is broadcast to all accounting nodes, so that all accounting nodes execute the unmarked transaction through the smart contract and update the world state of the blockchain ledger according to the transaction results. Finally, the transaction is returned to the client through the consensus node.

[0082] Figure 1 The execution subject of the blockchain contract scheduling method shown can be a consensus node. Figure 1 As can be seen from the process shown, the blockchain contract scheduling method of the embodiment of the present invention first packages the transaction into blocks and then conducts consensus, then broadcasts the blocks to all accounting nodes to be written into the blockchain ledger, and finally sends the transaction to the pre-selected accounting node according to the parallel state of the transaction contract, so that the accounting node updates the blockchain ledger written into the block according to the transaction result after executing the transaction, which can realize dynamic scheduling of the transaction process and thus improve the overall performance of the system.

[0083] Based on the same inventive concept, an embodiment of the present invention also provides a blockchain contract scheduling device. Since the principle of solving the problem by the device is similar to that of the blockchain contract scheduling method, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0084] Figure 5 It is a structural block diagram of the blockchain contract scheduling device in an embodiment of the present invention. Figure 6 This is a structural block diagram of a blockchain contract scheduling device, a client, and an accounting node in another embodiment of the present invention. Figure 5-Figure 6 As shown, the blockchain contract scheduling device is applied to the consensus node, and the consensus node and the accounting node constitute the blockchain network; the blockchain contract scheduling device includes:

[0085] The packaging module is used to obtain the transaction contract based on the transaction in the transaction request from the client, package the transaction into blocks, and then conduct consensus;

[0086] A broadcast module, used to broadcast the block to all accounting nodes so that all accounting nodes write the block into the blockchain ledger;

[0087] The sending module is used to send the transaction to the pre-selected accounting node according to the parallel state of the transaction contract, so that the accounting node can update the blockchain ledger written into the block according to the transaction result after executing the transaction.

[0088] In one embodiment, the sending module is specifically configured to:

[0089] When the parallel state of the transaction contract is parallel, the transaction is sent to the selected accounting node.

[0090] In one embodiment, it further includes:

[0091] The marking module is used to mark the transaction when the parallel status of the transaction contract is parallel;

[0092] The broadcast module is specifically used to: when the parallel state of the transaction contract is non-parallel, broadcast the block to all accounting nodes, so that all accounting nodes execute unmarked transactions and update the blockchain ledger according to the transaction results.

[0093] In one embodiment, it further includes:

[0094] The cache queue insertion module is used to receive historical transaction results including status key values ​​from the accounting node and put the historical transaction results into the corresponding contract cache queue;

[0095] The parallel state module is used to determine the parallel state of the transaction contract based on the number of historical transaction results and the number of each state key value in the contract cache queue.

[0096] In one embodiment, it further includes:

[0097] The accounting node selection module is used to generate a random number based on the hash value of the latest block to select an accounting node in the accounting node routing table.

[0098] like Figure 6 As shown in the figure, in actual applications, the client is used to organize transaction request messages, send transaction requests to any known consensus node through communication protocols such as http or grpc, and obtain return results.

[0099] The blockchain contract scheduling device applied to consensus nodes includes: a communication module, a data preprocessing module, a consensus module, an account book module, a data statistics module, and a node scheduling module. It is used to collect transactions and package them into blocks, and reach consensus on blocks among multiple nodes through consensus algorithms such as Raft and PBFT. In addition, it also provides reception statistics including account book status, as well as registration and scheduling of accounting nodes.

[0100] The communication module of the consensus node is used for consensus communication between consensus nodes, transaction communication and message response with the client, service registration and scheduling with the accounting node, and collection of transaction execution results.

[0101] The data preprocessing module of the consensus node is used for verification, collection and block packaging of transaction information.

[0102] The consensus module is used to provide consensus capabilities for various data between nodes, including consensus on accounting node registration information, contract parallel information, and block data.

[0103] The consensus node's ledger module records blockchain ledger data, primarily consisting of block data. Block data is stored as a file, chained together using block hashes to ensure data immutability. Block data is divided into two categories: configuration blocks, which record the latest channel configuration, including identity information, security policies, networking parameters, and other configuration information; and transaction blocks, which primarily contain a collection of transaction information.

[0104] The data statistics module determines whether there are conflicts in the operations of on-chain contracts on the world state of the blockchain ledger over a period of time. After the consensus node receives contract read and write information from the accounting node and reaches consensus within the consensus module, the data statistics module analyzes the data to determine whether the contract is suitable for parallel execution. The node scheduling module then dynamically adjusts the contract execution process.

[0105] The node scheduling module is used to dynamically adjust the transaction process. When a consensus node receives a transaction for a certain contract, it will dynamically schedule the accounting nodes in the transaction process based on the judgment made by the data statistics module on the conflict information of the contract in the recent period, and decide whether to execute the contract first and then submit consensus, or reach consensus first and then execute the contract.

[0106] The accounting node includes a communication module, a data preprocessing module, an account book module, and a smart contract module.

[0107] The accounting node's communication module is used for query communication between the accounting node and the client, block synchronization with the consensus node, node registration, read and write information push, and other message communication, as well as networking with the accounting node and block broadcast communication. When the node completes networking or a new node joins the network, the local network information is updated in real time. If the node is connected to the consensus node cluster, it will initiate registration with the consensus node and synchronize changes to the current network information to the consensus node cluster in real time.

[0108] The data preprocessing module of the accounting node provides legitimacy verification of the request message through a signature algorithm.

[0109] The ledger module of the accounting node is used to record blockchain ledger data. In addition to containing the same block data as the consensus node ledger module, it also contains world state data. World state data provides the latest state of the ledger for quick query and can be backtracked or reconstructed using block data.

[0110] The smart contract module manages the lifecycle of smart contracts and enables the contract's interaction with ledger data. Transactions simulate the execution of contracts based on the current ledger state through the smart contract module, obtaining transaction execution results that include ledger read and write sets. The read set contains the state key value read by the exchange and the current version number of the key value, and the write set contains the state key-value pairs written by the exchange.

[0111] In summary, the blockchain contract scheduling device of the embodiment of the present invention first packages the transaction into blocks and then conducts consensus, then broadcasts the blocks to all accounting nodes to be written into the blockchain ledger, and finally sends the transaction to the pre-selected accounting node according to the parallel state of the transaction contract, so that the accounting node updates the blockchain ledger written into the block according to the transaction result after executing the transaction, which can realize dynamic scheduling of the transaction process and thus improve the overall performance of the system.

[0112] The embodiment of the present invention also provides a specific implementation of a computer device that can implement all steps in the blockchain contract scheduling method in the above embodiment. Figure 7 This is a block diagram of the computer device in the embodiment of the present invention, see Figure 7 , the computer equipment specifically includes the following:

[0113] Processor 701 and memory 702 .

[0114] The processor 701 is configured to call the computer program in the memory 702. When the processor executes the computer program, all steps of the blockchain contract scheduling method in the above embodiment are implemented. For example, when the processor executes the computer program, the following steps are implemented:

[0115] Obtain the transaction contract based on the transaction in the transaction request from the client, package the transaction into blocks, and then conduct consensus;

[0116] Broadcast the block to all accounting nodes so that all accounting nodes write the block into the blockchain ledger;

[0117] The transaction is sent to a pre-selected accounting node based on the parallel state of the transaction contract, so that the accounting node can update the blockchain ledger written into the block according to the transaction result after executing the transaction.

[0118] In summary, the computer device of the embodiment of the present invention first packages the transaction into a block and then reaches a consensus, then broadcasts the block to all accounting nodes to be written into the blockchain ledger, and finally sends the transaction to the pre-selected accounting node according to the parallel state of the transaction contract, so that the accounting node updates the blockchain ledger written into the block according to the transaction result after executing the transaction, which can realize dynamic scheduling of the transaction process and thus improve the overall performance of the system.

[0119] The embodiment of the present invention also provides a computer-readable storage medium capable of implementing all steps of the blockchain contract scheduling method in the above embodiment. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, all steps of the blockchain contract scheduling method in the above embodiment are implemented. For example, when the processor executes the computer program, the following steps are implemented:

[0120] Obtain the transaction contract based on the transaction in the transaction request from the client, package the transaction into blocks, and then conduct consensus;

[0121] Broadcast the block to all accounting nodes so that all accounting nodes write the block into the blockchain ledger;

[0122] The transaction is sent to a pre-selected accounting node based on the parallel state of the transaction contract, so that the accounting node can update the blockchain ledger written into the block according to the transaction result after executing the transaction.

[0123] In summary, the computer-readable storage medium of the embodiment of the present invention first packages the transaction into a block and then conducts consensus, then broadcasts the block to all accounting nodes to be written into the blockchain ledger, and finally sends the transaction to the pre-selected accounting node according to the parallel state of the transaction contract, so that the accounting node updates the blockchain ledger written into the block according to the transaction result after executing the transaction, which can realize dynamic scheduling of the transaction process and thus improve the overall performance of the system.

[0124] The embodiments of the present invention also provide a computer program product capable of implementing all steps of the blockchain contract scheduling method in the above embodiment. The computer program product includes a computer program / instructions. When the computer program / instructions are executed by a processor, all steps of the blockchain contract scheduling method in the above embodiment are implemented. For example, when the processor executes the computer program, the following steps are implemented:

[0125] Obtain the transaction contract based on the transaction in the transaction request from the client, package the transaction into blocks, and then conduct consensus;

[0126] Broadcast the block to all accounting nodes so that all accounting nodes write the block into the blockchain ledger;

[0127] The transaction is sent to a pre-selected accounting node based on the parallel state of the transaction contract, so that the accounting node can update the blockchain ledger written into the block according to the transaction result after executing the transaction.

[0128] In summary, the computer program product of the embodiment of the present invention first packages the transaction into blocks and then conducts consensus, then broadcasts the blocks to all accounting nodes for writing into the blockchain ledger, and finally sends the transaction to the pre-selected accounting nodes according to the parallel state of the transaction contract, so that the accounting nodes can update the blockchain ledger written into the blocks according to the transaction results after executing the transactions, which can realize dynamic scheduling of the transaction process and thus improve the overall performance of the system.

[0129] Based on the same inventive concept, an embodiment of the present invention also provides a blockchain contract scheduling system. Since the principle of solving the problem by this system is similar to that of the blockchain contract scheduling method, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0130] Figure 8 This is a schematic diagram of the blockchain contract scheduling system in an embodiment of the present invention. Figure 8 As shown, the blockchain contract scheduling system includes:

[0131] Clients, consensus nodes, and accounting nodes; consensus nodes and accounting nodes constitute the blockchain network;

[0132] The consensus node obtains the transaction contract based on the transaction in the transaction request from the client, packages the transaction into a block, performs consensus, and broadcasts the block to all accounting nodes; according to the parallel status of the transaction contract, the transaction is sent to the pre-selected accounting node;

[0133] The accounting node writes the block into the blockchain ledger; after the transaction is executed, the blockchain ledger where the block was written is updated according to the transaction results.

[0134] The specific process of the blockchain contract scheduling system in this embodiment of the present invention is as follows:

[0135] 1. The client sends a transaction request to the consensus node.

[0136] 2. The consensus node obtains the transaction contract based on the transaction in the transaction request, packages the transaction into a block, reaches consensus, and broadcasts the block to all accounting nodes.

[0137] 3. The consensus node receives historical transaction results including state key values ​​from the accounting node and puts the historical transaction results into the corresponding contract cache queue.

[0138] 4. The consensus node determines the parallel status of the transaction contract based on the number of historical transaction results and the number of each state key value in the contract cache queue.

[0139] 5. The consensus node generates a random number based on the hash value of the latest block to select a bookkeeping node in the bookkeeping node routing table.

[0140] 6. When the parallel state of the transaction contract is parallel, the consensus node marks the transaction and sends it to the selected accounting node.

[0141] 7. The accounting node writes the block into the blockchain ledger, executes the unmarked transaction, and updates the blockchain ledger based on the transaction results.

[0142] In summary, the blockchain contract scheduling system provided by the embodiment of the present invention has the following beneficial effects:

[0143] 1. This invention combines the advantages of the "consensus-contract execution-submission" and "endorsement-consensus-verification-submission" processes to statistically classify transaction execution results to determine whether a contract can be executed in parallel. It also dynamically schedules the transaction process, using a first-execution, then-consensus block generation process for contracts that can be executed in parallel, and a first-consensus, then-execution block generation process for contracts that cannot be executed in parallel. This dynamic process scheduling fully combines the advantages of the "consensus-contract execution-submission" and "endorsement-consensus-verification-submission" mechanisms to improve blockchain transaction performance.

[0144] 2. If a read-write set conflict occurs during the parallel execution of a contract that is determined to be parallelizable, it will be re-marked as non-parallelizable to ensure that subsequent dependent transactions can be successfully executed. At the same time, the client will be notified to automatically resend the transaction to ensure that the application side is not affected.

[0145] 3. For the processing flow of parallel contracts, since some nodes need to be selected to execute the contract, in order to offset the problem of reduced security caused by reducing the number of contract execution nodes, nodes are selected through verifiable random numbers, and the transaction execution results are verified when the block is dropped. This prevents malicious nodes from having a continuous impact on the system, making the process of randomly selecting nodes safer.

[0146] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

[0147] Those skilled in the art will also appreciate that the various illustrative logical blocks, units, and steps listed in the embodiments of the present invention can be implemented by electronic hardware, computer software, or a combination of the two. To clearly demonstrate the interchangeability of hardware and software, the various illustrative components, units, and steps described above have generally described their functions. Whether such functions are implemented by hardware or software depends on the specific application and the design requirements of the entire system. Those skilled in the art may use various methods to implement the described functions for each specific application, but such implementation should not be understood as exceeding the scope of protection of the embodiments of the present invention.

[0148] The various illustrative logic blocks, units, or devices described in the embodiments of the present invention can be implemented or operated by a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field programmable gate array or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination thereof. The general-purpose processor can be a microprocessor, and optionally, the general-purpose processor can also be any conventional processor, controller, microcontroller, or state machine. The processor can also be implemented by a combination of computing devices, such as a digital signal processor and a microprocessor, a plurality of microprocessors, one or more microprocessors combined with a digital signal processor core, or any other similar configuration.

[0149] The steps of the methods or algorithms described in the embodiments of the present invention may be directly embedded in hardware, a software module executed by a processor, or a combination of the two. The software module may be stored in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. For example, the storage medium may be connected to the processor so that the processor can read information from the storage medium and write information to the storage medium. Alternatively, the storage medium may also be integrated into the processor. The processor and storage medium may be provided in an ASIC, which may be provided in a user terminal. Alternatively, the processor and storage medium may also be provided in different components in the user terminal.

[0150] In one or more exemplary designs, the above-mentioned functions described in the embodiments of the present invention can be implemented in hardware, software, firmware, or any combination of the three. If implemented in software, these functions can be stored on a computer-readable medium or transmitted in the form of one or more instructions or codes on a computer-readable medium. Computer-readable media include computer storage media and communication media that facilitate the transfer of computer programs from one location to another. Storage media can be any available medium that can be accessed by a general or special computer. For example, such computer-readable media can include but are not limited to RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to carry or store program code in the form of instructions or data structures and other forms that can be read by a general or special computer, or a general or special processor. In addition, any connection can be appropriately defined as a computer-readable medium. For example, if the software is transmitted from a website, server or other remote resource via a coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL), or wireless methods such as infrared, wireless, and microwave, it is also included in the definition of computer-readable media. The disks and discs mentioned above include compact disks, laser disks, optical disks, DVDs, floppy disks, and Blu-ray discs. Disks typically reproduce data magnetically, while discs typically reproduce data optically with lasers. Combinations of the above may also be included in computer-readable media.

Claims

1. A blockchain contract scheduling method, characterized in that: The blockchain contract scheduling method is applied to consensus nodes, and the consensus nodes and accounting nodes constitute a blockchain network; The blockchain contract scheduling method includes: Obtain the transaction contract based on the transaction in the transaction request from the client, package the transaction into a block, and then conduct consensus; Broadcasting the block to all accounting nodes so that all accounting nodes write the block into the blockchain ledger; Receive historical transaction results including state key values ​​from the accounting node, and put the historical transaction results into the corresponding contract cache queue; Determining the parallel state of the transaction contract based on the number of historical transaction results and the number of each state key value in the contract cache queue; When the parallel status of the transaction contract is parallel, marking the transaction; When the parallel state of the transaction contract is non-parallel, broadcasting the block to all accounting nodes, so that all accounting nodes execute the unmarked transaction and update the blockchain ledger according to the transaction results; When the parallel state of the transaction contract is parallel, the transaction is sent to a pre-selected accounting node, so that the accounting node updates the blockchain ledger written into the block according to the transaction result after executing the transaction.

2. The blockchain contract scheduling method according to claim 1, characterized in that: Pre-selected accounting nodes include: Generate a random number based on the hash value of the latest block to select the accounting node in the accounting node routing table.

3. A blockchain contract scheduling device, characterized in that: The blockchain contract scheduling device is applied to the consensus node, the consensus node and the accounting node constitute a blockchain network, and the blockchain contract scheduling device is used to execute the blockchain contract scheduling method according to claim 1; The blockchain contract scheduling device includes: The packaging module is used to obtain the transaction contract based on the transaction in the transaction request from the client, package the transaction into blocks, and then conduct consensus; A broadcast module, configured to broadcast the block to all accounting nodes, so that all accounting nodes write the block into the blockchain ledger; The cache queue insertion module is used to receive historical transaction results including status key values ​​from the accounting node and put the historical transaction results into the corresponding contract cache queue; The parallel state module is used to determine the parallel state of the transaction contract based on the number of historical transaction results and the number of each state key value in the contract cache queue; The sending module is used to send the transaction to the pre-selected accounting node when the parallel state of the transaction contract is parallel, so that the accounting node can update the blockchain ledger written into the block according to the transaction result after executing the transaction; The marking module is used to mark the transaction when the parallel status of the transaction contract is parallel; The broadcast module is specifically used to: when the parallel state of the transaction contract is non-parallel, broadcast the block to all accounting nodes, so that all accounting nodes execute unmarked transactions and update the blockchain ledger according to the transaction results.

4. A computer device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the steps of the blockchain contract scheduling method according to any one of claims 1 to 2 are implemented.

5. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the blockchain contract scheduling method according to any one of claims 1 to 2 are implemented.

6. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the blockchain contract scheduling method according to any one of claims 1 to 2 are implemented.

7. A blockchain contract scheduling system, characterized in that: include: Client, consensus node and accounting node; wherein the consensus node and accounting node constitute a blockchain network; The consensus node obtains a transaction contract based on the transaction in the transaction request from the client, packages the transaction into a block, performs consensus, and broadcasts the block to all accounting nodes; receives historical transaction results including status key values ​​from the accounting node, and places the historical transaction results into the corresponding contract cache queue; determines the parallel state of the transaction contract based on the number of historical transaction results and the number of each status key value in the contract cache queue; when the parallel state of the transaction contract is parallel, marks the transaction; when the parallel state of the transaction contract is non-parallel, broadcasts the block to all accounting nodes, so that all accounting nodes execute unmarked transactions and update the blockchain ledger according to the transaction results; when the parallel state of the transaction contract is parallel, sends the transaction to a pre-selected accounting node, so that the accounting node executes the transaction and updates the blockchain ledger written into the block according to the transaction results; The accounting node writes the block into the blockchain account book; after executing the transaction, the blockchain account book in which the block is written is updated according to the transaction result.

Citation Information

Patent Citations

  • Verification method and system for intelligent contract transactions in block chain

    CN107833060A

  • Money transferring method and device based on block chain, and storage medium

    CN108846659A