Blockchain-based transaction execution method, device, equipment and storage medium

By introducing the root chain and the shard chain into the blockchain, the shard chain obtains the blocks and transmits them to the root chain for packaging and confirmation, which solves the problem of low throughput of the blockchain consensus system in the existing technology and realizes It supports high-frequency chain usage scenarios and improves transaction throughput.

CN115834592BActive Publication Date: 2024-09-06CHINA MOBILE QUANTONG SYST INTEGRATION CO LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111087971.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-16
Publication Date
2024-09-06
Estimated Expiration
2041-09-16

AI Technical Summary

Technical Problem

The existing blockchain consensus system based on the HotStuff algorithm has low throughput and cannot support high-frequency chain usage scenarios.

Method used

By introducing the root chain and the shard chain into the blockchain, the shard chain obtains the blocks and transmits them to the root chain for packaging and confirmation, realizing the coordinated operation of the shard chains under the coordination of the root chain and increasing the number of shard chains. To improve the transaction throughput of the entire network.

Benefits of technology

It supports high-frequency chain usage scenarios, improves the transaction throughput of the blockchain, can handle 10,000 transactions per second, and improves the security of the blockchain.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115834592B
    Figure CN115834592B
Patent Text Reader

Abstract

The present invention provides a transaction execution method, device, equipment and storage medium based on blockchain, the method comprising: the first shard chain in the blockchain obtains the first block corresponding to the target transaction; the first shard chain transmits the block header of the first block to the root chain in the blockchain, so that the root chain performs a packaging operation on the block header and obtains a second block, the second block is used by the root chain to confirm that the first block is credible and the root chain sends a message for confirming that the first block is credible; the first shard chain determines the execution process of completing the target transaction based on the message; wherein the blockchain includes a root chain and at least one shard chain. The present invention sets the blockchain to include a root chain and at least one shard chain, the shard chain obtains the first block to record the target transaction, the root chain packages the block header of the first block to obtain the second block for final confirmation of the target transaction, and realizes that at least one shard chain can be coordinated under the coordination of the root chain to support high-frequency chain scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a transaction execution method, device, equipment and storage medium based on blockchain. Background Art

[0002] The master-node-based Byzantine fault-tolerant consensus protocol HotStuff algorithm is a PBFT-type consensus algorithm for blockchain. For example, the consensus algorithm used by the blockchain project Libra is based on the HotStuff algorithm. Through aggregate signatures and pipeline design, the algorithm's communication complexity and computational complexity are reduced to O(n).

[0003] However, the current consensus system based on the HotStuff algorithm can only support a maximum of 1,000 transactions per second and cannot support high-frequency chain usage scenarios. Therefore, the existing consensus system has the problem of low throughput. Summary of the invention

[0004] The present invention provides a transaction execution method, device, equipment and storage medium based on blockchain, which are used to solve the problem of low throughput of the consensus system in the prior art and enable blockchain to support high-frequency chain usage scenarios during the transaction consensus process.

[0005] In a first aspect, the present invention provides a transaction execution method based on blockchain, comprising:

[0006] The first shard chain in the blockchain obtains the first block corresponding to the target transaction;

[0007] The first shard chain transmits the block header of the first block to the root chain in the blockchain, so that the root chain performs a packaging operation on the block header to obtain a second block, and the second block is used by the root chain to confirm that the first block is credible and the root chain sends a message for confirming that the first block is credible;

[0008] The first shard chain determines, based on the message, an execution process for completing the target transaction;

[0009] The blockchain includes the root chain and at least one shard chain.

[0010] In one embodiment, the first shard chain determines, based on the message, a process for completing the execution of the target transaction, including:

[0011] The first shard chain confirms that the first block is credible based on the message;

[0012] The first shard chain calculates the address of the target execution node of the target transaction based on the address of the task initiating node of the target transaction;

[0013] The first shard chain determines, based on the address of the target execution node, whether the target execution node is in the first shard chain;

[0014] If the target execution node is in the first shard chain, executing the target transaction in the first shard chain;

[0015] If the target execution node is not in the first shard chain, the second shard chain where the target execution node is located is determined to be the shard chain that executes the cross-chain part of the target transaction.

[0016] In one embodiment, the first shard chain determines, based on the message, a process for completing the execution of the target transaction, including:

[0017] The first shard chain confirms that the first block is credible based on the message;

[0018] The first shard chain executes the target transaction.

[0019] In one embodiment, the first shard chain in the blockchain obtains a first block corresponding to a target transaction, including:

[0020] The first shard chain performs a first voting operation on the transaction requiring consensus to obtain a target transaction;

[0021] The first shard chain performs a second voting operation on the proposal of the target transaction to obtain the first block.

[0022] In a second aspect, the present invention provides a transaction execution method based on blockchain, comprising:

[0023] The root chain in the blockchain receives the block header of the first block corresponding to the target transaction, where the first block is obtained by the first shard chain in the blockchain;

[0024] The root chain performs a packaging operation on the block header to obtain a second block;

[0025] The root chain confirms that the first block is credible based on the second block, and sends a message for confirming that the first block is credible, so that the first shard chain determines to complete the execution process of the target transaction based on the message;

[0026] The blockchain includes the root chain and at least one shard chain.

[0027] In one embodiment, the root chain confirms that the first block is credible based on the second block, and sends a message for confirming that the first block is credible, including:

[0028] In the case where the first block includes a forked block, the root chain filters out a target forked block from the forked block based on the second block corresponding to the forked block;

[0029] The root chain sends a message to confirm that the target forked block is credible.

[0030] In a third aspect, the present invention provides a transaction execution device based on blockchain, comprising:

[0031] A first acquisition module, used for the first shard chain in the blockchain to acquire the first block corresponding to the target transaction;

[0032] A transmission module, configured for the first shard chain to transmit the block header of the first block to the root chain in the blockchain, so that the root chain performs a packaging operation on the block header to obtain a second block, and the second block is used by the root chain to confirm that the first block is credible and the root chain sends a message for confirming that the first block is credible;

[0033] A determination module, configured for the first shard chain to determine an execution process for completing the target transaction based on the message;

[0034] The blockchain includes the root chain and at least one shard chain.

[0035] In a fourth aspect, the present invention provides a transaction execution device based on blockchain, comprising:

[0036] A receiving module, configured to receive a block header of a first block corresponding to a target transaction from a root chain in a blockchain, where the first block is obtained from a first shard chain in the blockchain;

[0037] A second acquisition module is used for the root chain to perform a packaging operation on the block header to obtain a second block;

[0038] A confirmation module, used for the root chain to confirm that the first block is credible based on the second block, and to send a message for confirming that the first block is credible, so that the first shard chain determines to complete the execution process of the target transaction based on the message;

[0039] The blockchain includes the root chain and at least one shard chain.

[0040] In a fifth aspect, the present invention provides an electronic device comprising a memory and a memory storing a computer program, wherein when the processor executes the program, the steps of the blockchain-based transaction execution method described in the first aspect or the second aspect are implemented.

[0041] In a sixth aspect, the present invention provides a processor-readable storage medium, wherein the processor-readable storage medium stores a computer program, and the computer program is used to enable the processor to execute the steps of the blockchain-based transaction execution method described in the first aspect or the second aspect.

[0042] The present invention provides a blockchain-based transaction execution method, device, equipment and storage medium. The blockchain is set to include a root chain and at least one shard chain. The shard chain obtains a first block for recording a target transaction. The root chain packages the block header of the first block to obtain a second block for final confirmation of the target transaction. This enables at least one shard chain to operate collaboratively under the coordination of the root chain, thereby increasing the transaction throughput of the entire network by increasing the number of shard chains, and supporting high-frequency chain usage scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0044] Figure 1 It is a flowchart of the basic HotStuff algorithm provided by the relevant technology;

[0045] Figure 2 It is a flow chart of the pipelined HotStuff algorithm provided by the related technology;

[0046] Figure 3 This is one of the flowcharts of the transaction execution method based on blockchain provided by the present invention;

[0047] Figure 4 It is a schematic diagram of the blockchain architecture provided by the present invention;

[0048] Figure 5 This is the second flow chart of the transaction execution method based on blockchain provided by the present invention;

[0049] Figure 6 This is one of the structural schematic diagrams of the transaction execution device based on blockchain provided by the present invention;

[0050] Figure 7 This is the second structural schematic diagram of the transaction execution device based on blockchain provided by the present invention;

[0051] Figure 8 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0052] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are 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 creative work are within the scope of protection of the present invention.

[0053] Hotstuff, a masternode-based Byzantine fault-tolerant consensus protocol, provides a linear and responsive Byzantine Fault Tolerance (BFT) protocol.

[0054] Figure 1 This is a flowchart of the basic HotStuff algorithm provided by related technologies, such as Figure 1 As shown in FIG. 1 , the basic HotStuff algorithm process includes: Prepare Phase, Pre-Commit Phase, Commit Phase, and Decide Phase.

[0055] Prepare Phase: The consensus process starts with the new primary node (leader node) collecting new view messages from replicas. When the leader node has collected requests from enough replicas, it will start a new view and make its own state transition request, and then send a prepare message to other nodes. Figure 1 As shown in the figure, the N1 node acts as the leader node. When it collects requests from the N2 node, the N3 node, and the N4 node, the N1 node will start a new view and make its own state transition request, and then send a prepare message to other nodes.

[0056] After receiving the prepare message, other nodes in the system will verify its legitimacy and confirm the message according to the following three stages:

[0057] Pre-Commit Phase: When the leader node receives the prepare ticket for the current proposal, it merges it into a prepare arbitration certificate and then broadcasts it to all nodes in the form of a pre-commit message, indicating that enough nodes have confirmed the state transition request. Figure 1As shown, the N1 node acts as the leader node. When the N1 node receives the prepare vote (Prepare Vote) of the current proposal, the N1 node merges it into a prepare arbitration certificate, and then broadcasts the prepare arbitration certificate to the N2 nodes, N3 nodes, and N4 nodes in the form of a pre-commit message (Pre-Commit).

[0058] Commit Phase: After the leader node receives the Pre-Commit votes, it combines them into a pre-commit arbitration certificate (precommitQC) and broadcasts it to all nodes in the form of a commit message; the replicas that receive the message can lock the current state transition request so that a consensus decision can be reached even during view changes. Figure 1 As shown, the N1 node acts as the leader node. After receiving the second-stage votes (Pre-Commit Vote), N1 combines them into precommitQC and broadcasts precommitQC to the N2 nodes, N3 nodes, and N4 nodes in the form of a commit message (Commit).

[0059] Decide Phase: After the leader node receives the commit votes, it merges them into a commit arbitration certificate (commitQC). Once the leader node has formed a commitQC, it sends a decision message to all other replicas. After receiving the confirmation message, the replica will perform the state transition in the committed branch and start the next view. Figure 1 As shown in the figure, the N1 node acts as the leader node. After receiving the commit votes (Commit Vote), the N1 node merges them into commitQC and broadcasts commitQC to the N2 nodes, N3 nodes and N4 nodes in the form of a decision message (Decide).

[0060] It can be seen that the three confirmation stages of HotStuff have the same structure: other nodes vote on the message, and the leader node combines these votes and broadcasts them to other nodes. These stages can be represented uniformly and pipelined.

[0061] Figure 2 This is a flow chart of the pipelined HotStuff algorithm provided by the related technology, such as Figure 2 As shown, Figure 2PREPARE, PRE-COMMIT, COMMIT, and DECIDE in the figure correspond to the preparation phase, pre-commit phase, commit phase, and decision phase of a view, respectively. v1, v2, v3, v4, and v5 represent views in the pipelined HotStuff. cmd1, cmd2, cmd3, cmd4, and cmd5 correspond to the commands submitted by v1, v2, v3, v4, and v5, respectively. QC represents the arbitration certificate.

[0062] Pipelined HotStuff is a variation and extension of the basic HotStuff. In pipelined HotStuff, votes for the prepare phase are collected by the leader node of the next view of the prepare phase arbitration certificate (prepareQC). Similarly, votes for the pre-commit and commit phases are also collected by the leader node of the next corresponding view.

[0063] exist Figure 2 In the example, the new leader node is in the prepare phase of view v2 and also serves as the pre-commit phase of view v1. The new leader node is in the prepare phase of view v3 and also serves as the pre-commit phase of view v2 and the commit phase of view v1.

[0064] exist Figure 2 In the figure, views v1, v2, and v3 serve as the prepare, pre-commit, and commit stages of command cmd1 submitted by v1, and command cmd1 is confirmed in view v4; views v2, v3, and v4 serve as the three basic HotStuff stages of cmd2 submitted by v2, and cmd2 is confirmed in view v5.

[0065] It can be seen that HotStuff is a single-chain consensus. The consensus system based on Hotstuff has problems such as low throughput, long transaction confirmation time, and limited application scenarios, and cannot support high-frequency chain usage scenarios.

[0066] Figure 3 This is one of the flowcharts of the transaction execution method based on blockchain provided by the present invention, such as Figure 3 As shown, the method includes:

[0067] Step 301: The first shard chain in the blockchain obtains the first block corresponding to the target transaction;

[0068] Optionally, the blockchain may include the root chain and at least one shard chain.

[0069] Figure 4This is a schematic diagram of the blockchain architecture provided by the present invention, such as Figure 4 As shown, the blockchain architecture can be set up with a root chain and multiple shard chains, where the root chain can be used to confirm the blocks of the shard chains and ensure the security of the shard chains, and the shard chains can be used to execute transactions.

[0070] Optionally, the root chain can be deployed on a virtual machine such as Figure 4 As shown, the root chain is deployed on virtual machine 0.

[0071] Optionally, multiple shard chains can be deployed on the same virtual machine, such as Figure 4 As shown, shard chain 0 and shard 1 are both deployed on virtual machine 1.

[0072] Optionally, multiple shard chains can be deployed on different virtual machines, such as Figure 4 As shown, shard chain 2 is deployed on virtual machine 2, and shard chain 3 is deployed on virtual machine 3.

[0073] Optionally, the shard chain and the root chain can interact through a Representational State Transfer-ful Application Programming Interface (Restful API).

[0074] Optionally, the root chain and each shard chain have their own independent peer-to-peer (P2P) network for communication and broadcasting between nodes.

[0075] Optionally, the first shard chain can be a shard chain in the blockchain architecture.

[0076] Optionally, the target transaction may be all or part of the transactions requiring consensus on the first shard chain.

[0077] Optionally, the first shard chain can use basic HotStuff to obtain the first block corresponding to the target transaction.

[0078] Optionally, the first shard chain can use pipelined HotStuff to obtain the first block corresponding to the target transaction.

[0079] Therefore, the first block regarding the target transaction can be obtained through the first shard chain, and the block header of the first block can be used for subsequent root chain packaging operations.

[0080] Step 302: The first shard chain transmits the block header of the first block to the root chain in the blockchain, so that the root chain performs a packaging operation on the block header to obtain a second block, and the second block is used by the root chain to confirm that the first block is credible and the root chain sends a message for confirming that the first block is credible;

[0081] Optionally, the first shard chain may interact with the root chain via a Restful API, thereby transmitting the block header of the first block to the root chain in the blockchain.

[0082] Optionally, the root chain may use the basic HotStuff consensus algorithm to perform a packaging operation on the block header of the first block to obtain the second block.

[0083] Optionally, the root chain may use a pipelined HotStuff consensus algorithm to perform a packaging operation on the block header of the first block to obtain the second block.

[0084] Optionally, the root chain may use a Proof of Work (PoW) consensus algorithm to perform a packaging operation on the block header of the first block to obtain the second block.

[0085] Optionally, the root chain may use a Proof of Staked (PoS) consensus algorithm to perform a packaging operation on the block header of the first block to obtain the second block.

[0086] Optionally, the root chain may use a Delegated Proof of Stake (DPoS) consensus algorithm to perform a packaging operation on the block header of the first block to obtain the second block.

[0087] Optionally, the first shard chain can adopt the HotStuff consensus algorithm and introduce the root chain priority principle in the three confirmation stages of HotStuff. The root chain priority principle can be that after the first shard chain obtains the first block corresponding to the target transaction based on the HotStuff consensus algorithm, the root chain packages the block header of the first block to obtain the second block, and finally confirms the first block based on the second block of the root chain, and then finally confirms the target transaction.

[0088] Therefore, the first shard chain can transmit the block header of the first block to the root chain, and then the root chain can obtain the second block by performing a packaging operation. The second block is used by the root chain to confirm that the first block is credible and send a message for confirming that the first block is credible.

[0089] Step 303: The first shard chain determines the execution process of completing the target transaction based on the message.

[0090] Optionally, after receiving a message confirming that the first block is credible, the first shard chain determines to complete the execution process of the target transaction.

[0091] Optionally, determining the execution process of completing the target transaction may include executing the target transaction only on the first shard chain.

[0092] Optionally, determining the execution process of completing the target transaction may include determining whether the target transaction involves a cross-chain transaction.

[0093] Optionally, determining the execution process for completing the target transaction may include executing the target transaction on the first shard chain based on a determination that the target transaction does not involve a cross-chain transaction.

[0094] Optionally, determining the execution process of completing the target transaction may include, based on a judgment that the target transaction involves a cross-chain transaction, executing the transaction portion of the target transaction related to the first shard chain on the first shard chain, confirming the second shard chain corresponding to the cross-chain transaction portion in the target transaction, and then executing the cross-chain transaction portion in the target transaction by the second shard chain.

[0095] Therefore, after the root chain confirms that the first block is credible, the first shard chain can determine the execution process to complete the target transaction, and then complete the target transaction based on the execution process, where the target transaction can be a cross-chain transaction.

[0096] Optionally, after the root chain is introduced into the blockchain, the root chain can be used to coordinate the shard chains, receive the block header of the first block generated by each shard chain, and package the block header of the first block into the second block. After the second block is packaged, after notifying each shard chain that the first block is finally confirmed to be credible based on the second block, the cross-chain part of the cross-chain transaction corresponding to the confirmed credible first block can be executed.

[0097] It is understandable that by setting up a blockchain including a root chain and at least one shard chain, the shard chain obtains the first block for recording the target transaction, and the root chain packages the block header of the first block to obtain the second block for final confirmation of the target transaction, so that at least one shard chain can be coordinated and run under the coordination of the root chain to support cross-shard transactions. In addition, the transaction execution capability of the blockchain can be expanded horizontally by adding shard chains, the transaction throughput of the entire network can be improved, and high-frequency chain scenarios can be supported, such as supporting a throughput of 10,000 transactions per second.

[0098] It is understandable that the introduction of the root chain in the blockchain architecture is used to confirm the blocks of the shard chain, coordinate the shard chain, support cross-chain operations, and also improve the overall security of the blockchain. When the blockchain is attacked, the root chain and the shard need to be attacked at the same time to rewrite the confirmed blocks, which increases the difficulty of the attack and thus improves the security.

[0099] It is understandable that the shard chain can adopt the HotStuff consensus algorithm and introduce the root chain priority principle in the three confirmation stages of HotStuff. In addition to the changes in the final confirmation rules, the other processes of the modified HotStuff are consistent with the previous ones, so that the original advantages of HotStuff are still there and it is compatible with the original HotStuff. The workload of replacing projects developed based on HotStuff with the modified HotStuff consensus is lower.

[0100] The blockchain-based transaction execution method provided by the present invention, by setting the blockchain to include a root chain and at least one shard chain, the shard chain obtains a first block for recording a target transaction, and the root chain packages the block header of the first block to obtain a second block for final confirmation of the target transaction, thereby achieving at least one shard chain being able to operate collaboratively under the coordination of the root chain, and further increasing the number of shard chains to improve the transaction throughput of the entire network, supporting high-frequency chain usage scenarios.

[0101] Optionally, the first shard chain determines, based on the message, an execution process for completing the target transaction, including:

[0102] The first shard chain confirms that the first block is credible based on the message;

[0103] The first shard chain calculates the address of the target execution node of the target transaction based on the address of the task initiating node of the target transaction;

[0104] The first shard chain determines, based on the address of the target execution node, whether the target execution node is in the first shard chain;

[0105] If the target execution node is in the first shard chain, executing the target transaction in the first shard chain;

[0106] If the target execution node is not in the first shard chain, the second shard chain where the target execution node is located is determined to be the shard chain that executes the cross-chain part of the target transaction.

[0107] Optionally, when the blockchain supports cross-chain transactions, the first shard chain can calculate the address of the target execution node of the target transaction based on the address of the task initiating node of the target transaction, and then determine whether the target execution node is in the first shard chain based on the address of the target execution node.

[0108] Optionally, when it is determined that the target execution node is in the first shard chain, the first shard chain can execute the target transaction.

[0109] Optionally, when it is determined that the target execution node is not in the first shard chain, the second shard chain where the target execution node is located can execute the cross-chain part of the target transaction.

[0110] Therefore, after the root chain confirms that the first block is credible, the first shard chain can determine the execution process to complete the target transaction, and then complete the target transaction based on the execution process, where the target transaction can be a cross-chain transaction to support cross-chain operations.

[0111] Optionally, the first shard chain determines, based on the message, an execution process for completing the target transaction, including:

[0112] The first shard chain confirms that the first block is credible based on the message;

[0113] The first shard chain executes the target transaction.

[0114] Optionally, when the blockchain does not support cross-chain transactions, the first shard chain can directly execute the target transaction corresponding to the first block after confirming that the first block is credible.

[0115] Therefore, after the root chain confirms that the first block is credible, the first shard chain can determine the execution process to complete the target transaction, and then complete the target transaction based on the execution process, wherein the target transaction can be compatible with single-chain transactions.

[0116] Optionally, the first shard chain in the blockchain obtains a first block corresponding to the target transaction, including:

[0117] The first shard chain performs a first voting operation on the transaction requiring consensus to obtain a target transaction;

[0118] The first shard chain performs a second voting operation on the proposal of the target transaction to obtain the first block.

[0119] Optionally, the first shard chain in the blockchain obtains the first block corresponding to the target transaction in two stages. The first stage may be that the first shard chain performs a first voting operation on the transaction requiring consensus to obtain the target transaction, and the second stage may be that the first shard chain performs a second voting operation on the proposal of the target transaction to obtain the first block.

[0120] Optionally, multiple rounds of first voting operations may be performed in the first stage.

[0121] Optionally, the first voting operation may include four sub-operations: a collection sub-operation, a union sub-operation, an exchange voting sub-operation, and a generate target transaction sub-operation.

[0122] Optionally, the collection sub-operation of the first voting operation may be that each node collects as many transactions that require consensus as possible at the beginning of the consensus and puts them into the "candidate set".

[0123] Optionally, the union sub-operation of the first voting operation may be that each node performs a union of the "candidate sets" in its trusted node list and votes on each transaction.

[0124] Optionally, the communication voting sub-operation of the first voting operation may be that the service nodes in the trusted node list communicate the voting results of the transaction, and transactions that reach a certain voting ratio will enter the next round, and transactions that do not reach the ratio will be discarded or enter the candidate set of the next consensus process.

[0125] Optionally, the target transaction generation sub-operation of the first voting operation may be that in the final round, all transactions with votes exceeding a preset ratio value (eg, 80%) are placed in the target transaction.

[0126] Optionally, the target transaction may adopt a hash binary tree (Merkle) data structure.

[0127] Optionally, the second voting operation may include three sub-operations: a block hash calculation sub-operation, a broadcast sub-operation, and a block collection sub-operation.

[0128] Optionally, the calculation block hash sub-operation of the second voting operation may be to put together the new block number, the Merkle tree root Hash of the target transaction, the parent block Hash, the current timestamp and other contents to calculate the block hash.

[0129] Optionally, the broadcast sub-operation of the second voting operation may be that each node broadcasts its derived block hash to the nodes that it can see.

[0130] Optionally, the block collection sub-operation of the second voting operation can be that after the node collects the block hashes broadcasted by all nodes in its trusted list, it calculates the number of occurrences of each block hash (i.e., the number of times each node "votes" for the block hash) in combination with the block hash generated by this node. If the ratio of a block hash exceeds a threshold (e.g., 80%), the block hash is considered to be the hash of a block that has passed consensus.

[0131] Optionally, if the block hash generated by this node is the same as it, it means that the block packaged by this node has been confirmed and is a new consensus block. It is directly stored locally and the status is updated.

[0132] Optionally, if the block hash generated by this node is different from the hash passed by consensus, it is necessary to go to a node with the correct block hash to request new block information, then store it locally and update the current status.

[0133] Optionally, if the number of occurrences (voting ratio) of any block hash in the collecting block sub-operation of the second voting operation does not exceed the set threshold, the consensus process is restarted until the condition is met.

[0134] Therefore, the first shard chain performs a first voting operation on the transaction requiring consensus, and can obtain the target transaction. The first shard chain performs a second voting operation on the proposal of the target transaction, and obtains the first block. The block header of the first block can be used for the root chain packaging operation.

[0135] The blockchain-based transaction execution method provided by the present invention, by setting the blockchain to include a root chain and at least one shard chain, the first shard chain performs a first voting operation and a second voting operation on the transaction requiring consensus to obtain a first block, the block header of the first block can be used for the root chain packaging operation, the root chain packages the block header of the first block to obtain a second block for final confirmation of the target transaction, thereby achieving at least one shard chain being able to operate collaboratively under the coordination of the root chain, and further the transaction throughput of the entire network can be increased by increasing the number of shard chains, supporting high-frequency chain usage scenarios.

[0136] Figure 5 This is the second flow chart of the transaction execution method based on blockchain provided by the present invention, such as Figure 5 As shown, the method includes:

[0137] Step 501: The root chain in the blockchain receives the block header of the first block corresponding to the target transaction, where the first block is obtained by the first shard chain in the blockchain;

[0138] Optionally, the blockchain may include the root chain and at least one shard chain.

[0139] Optionally, the shard chain and the root chain can interact through a Restful API.

[0140] Optionally, the root chain and each shard chain have their own independent P2P network for communication and broadcasting between nodes.

[0141] Optionally, the first shard chain can be a shard chain in the blockchain architecture.

[0142] Optionally, the target transaction may be all or part of the transactions requiring consensus on the first shard chain.

[0143] Optionally, the first shard chain can use basic HotStuff to obtain the first block corresponding to the target transaction.

[0144] Optionally, the first shard chain can use pipelined HotStuff to obtain the first block corresponding to the target transaction.

[0145] Optionally, the first shard chain may interact with the root chain via a Restful API, thereby transmitting the block header of the first block to the root chain in the blockchain.

[0146] Therefore, the first block regarding the target transaction can be obtained through the first shard chain, and the block header of the first block can be used for subsequent root chain packaging operations.

[0147] Step 502: the root chain performs a packaging operation on the block header to obtain a second block;

[0148] Optionally, the root chain may use the basic HotStuff consensus algorithm to perform a packaging operation on the block header of the first block to obtain the second block.

[0149] Optionally, the root chain may use a pipelined HotStuff consensus algorithm to perform a packaging operation on the block header of the first block to obtain the second block.

[0150] Optionally, the root chain may use a Proof of Work (PoW) consensus algorithm to perform a packaging operation on the block header of the first block to obtain the second block.

[0151] Optionally, the root chain may use a Proof of Staked (PoS) consensus algorithm to perform a packaging operation on the block header of the first block to obtain the second block.

[0152] Optionally, the root chain may use a Delegated Proof of Stake (DPoS) consensus algorithm to perform a packaging operation on the block header of the first block to obtain the second block.

[0153] Optionally, the first shard chain can adopt the HotStuff consensus algorithm and introduce the root chain priority principle in the three confirmation stages of HotStuff. The root chain priority principle can be that after the first shard chain obtains the first block corresponding to the target transaction based on the HotStuff consensus algorithm, the root chain packages the block header of the first block to obtain the second block.

[0154] Therefore, the first shard chain can transmit the block header of the first block to the root chain, and then the root chain can obtain the second block by performing a packaging operation. The second block is used by the root chain to confirm that the first block is credible and send a message for confirming that the first block is credible.

[0155] Step 503: The root chain confirms that the first block is credible based on the second block, and sends a message for confirming that the first block is credible, so that the first shard chain determines to complete the execution process of the target transaction based on the message.

[0156] Optionally, the root chain may confirm that the first block is credible based on the second block, and may send a message to the first shard chain to confirm that the first block is credible.

[0157] Optionally, after receiving a message confirming that the first block is credible, the first shard chain determines to complete the execution process of the target transaction.

[0158] Optionally, determining the execution process of completing the target transaction may include executing the target transaction only on the first shard chain.

[0159] Optionally, determining the execution process of completing the target transaction may include determining whether the target transaction involves a cross-chain transaction.

[0160] Optionally, determining the execution process for completing the target transaction may include executing the target transaction on the first shard chain based on a determination that the target transaction does not involve a cross-chain transaction.

[0161] Optionally, determining the execution process of completing the target transaction may include, based on a judgment that the target transaction involves a cross-chain transaction, executing the transaction portion of the target transaction related to the first shard chain on the first shard chain, confirming the second shard chain corresponding to the cross-chain transaction portion in the target transaction, and then executing the cross-chain transaction portion in the target transaction by the second shard chain.

[0162] Therefore, after the root chain confirms that the first block is credible, the first shard chain can determine the execution process to complete the target transaction, and then complete the target transaction based on the execution process, where the target transaction can be a cross-chain transaction.

[0163] Optionally, after the root chain is introduced into the blockchain, the root chain can be used to coordinate the shard chains, receive the block header of the first block generated by each shard chain, and package the block header of the first block into the second block. After the second block is packaged, after notifying each shard chain that the first block is finally confirmed to be credible based on the second block, the cross-chain part of the cross-chain transaction corresponding to the confirmed credible first block can be executed.

[0164] The blockchain-based transaction execution method provided by the present invention, by setting the blockchain to include a root chain and at least one shard chain, the shard chain obtains a first block for recording a target transaction, and the root chain packages the block header of the first block to obtain a second block for final confirmation of the target transaction, thereby achieving at least one shard chain being able to operate collaboratively under the coordination of the root chain, and further increasing the number of shard chains to improve the transaction throughput of the entire network, supporting high-frequency chain usage scenarios.

[0165] Optionally, the root chain confirms that the first block is credible based on the second block, and sends a message for confirming that the first block is credible, including:

[0166] In the case where the first block includes a forked block, the root chain filters out a target forked block from the forked block based on the second block corresponding to the forked block;

[0167] The root chain sends a message to confirm that the target forked block is credible.

[0168] Optionally, a fork may occur in the process of the first shard chain acquiring the first block, and the first block when the fork occurs may be a forked block.

[0169] Optionally, when a fork occurs in the first shard chain, the first block may include two or more forked blocks.

[0170] Optionally, in the event of a fork in the first shard chain, the root chain filters out a target forked block from the forked block based on the second block corresponding to the forked block. The basis for the screening may be that the chain length of the second block corresponding to the target forked block is longer than the chain lengths of the second blocks corresponding to other forked blocks.

[0171] Optionally, in the event that a fork occurs in the first shard chain, the target forked block in the first block is a trusted block, and other forked blocks in the first block except the target forked block are untrusted blocks.

[0172] Therefore, the root chain is introduced into the blockchain architecture to confirm the blocks of the shard chain, coordinate the shard chain, support cross-chain operations, and also improve the overall security of the blockchain. When the blockchain is attacked, the root chain and the shard need to be attacked at the same time to rewrite the confirmed blocks, which increases the difficulty of the attack and thus improves the security.

[0173] The blockchain-based transaction execution method provided by the present invention, by setting the blockchain to include a root chain and at least one shard chain, the shard chain obtains a first block for recording a target transaction, the root chain packages the block header of the first block to obtain a second block for final confirmation of the target transaction, so that at least one shard chain can be coordinated and run in coordination with the root chain, and then when the blockchain is attacked, the root chain and the shard need to be attacked at the same time to rewrite the confirmed block, which increases the difficulty of attack and thus improves security.

[0174] The blockchain-based transaction execution device provided by the present invention is described below. The blockchain-based transaction execution device described below and the blockchain-based transaction execution method described above can refer to each other.

[0175] Figure 6 is one of the structural diagrams of the transaction execution device based on blockchain provided by the present invention, such as Figure 6As shown, the device includes: a first acquisition module 601, a transmission module 602 and a determination module 603, wherein:

[0176] The first acquisition module 601 is used for the first shard chain in the blockchain to obtain the first block corresponding to the target transaction;

[0177] The transmission module 602 is used for the first shard chain to transmit the block header of the first block to the root chain in the blockchain, so that the root chain performs a packaging operation on the block header to obtain a second block, and the second block is used by the root chain to confirm that the first block is credible and the root chain sends a message for confirming that the first block is credible;

[0178] The determination module 603 is used for the first shard chain to determine the execution process of completing the target transaction based on the message;

[0179] The blockchain includes the root chain and at least one shard chain.

[0180] Optionally, after the root chain is introduced into the blockchain, the root chain can be used to coordinate the shard chains, receive the block header of the first block generated by each shard chain, and package the block header of the first block into the second block. After the second block is packaged, after notifying each shard chain that the first block is finally confirmed to be credible based on the second block, the cross-chain part of the cross-chain transaction corresponding to the confirmed credible first block can be executed.

[0181] The blockchain-based transaction execution device provided by the present invention, by setting the blockchain to include a root chain and at least one shard chain, the shard chain obtains a first block for recording a target transaction, and the root chain packages the block header of the first block to obtain a second block for final confirmation of the target transaction, thereby achieving at least one shard chain being able to operate collaboratively under the coordination of the root chain, and further increasing the number of shard chains to increase the transaction throughput of the entire network, supporting high-frequency chain usage scenarios.

[0182] Optionally, the determining module includes:

[0183] The first shard chain confirms that the first block is credible based on the message;

[0184] The first shard chain calculates the address of the target execution node of the target transaction based on the address of the task initiating node of the target transaction;

[0185] The first shard chain determines, based on the address of the target execution node, whether the target execution node is in the first shard chain;

[0186] If the target execution node is in the first shard chain, executing the target transaction in the first shard chain;

[0187] If the target execution node is not in the first shard chain, the second shard chain where the target execution node is located is determined to be the shard chain that executes the cross-chain part of the target transaction.

[0188] Optionally, the determining module includes:

[0189] The first shard chain confirms that the first block is credible based on the message;

[0190] The first shard chain executes the target transaction.

[0191] Optionally, the first acquisition module includes:

[0192] The first shard chain performs a first voting operation on the transaction requiring consensus to obtain a target transaction;

[0193] The first shard chain performs a second voting operation on the proposal of the target transaction to obtain the first block.

[0194] The blockchain-based transaction execution device provided by the present invention, by setting the blockchain to include a root chain and at least one shard chain, the first shard chain executes the first voting operation and the second voting operation to obtain the first block, the root chain packages the block header of the first block to obtain the second block for final confirmation of the target transaction, and realizes that at least one shard chain can operate collaboratively under the coordination of the root chain, and then the transaction throughput of the entire network can be improved by increasing the number of shard chains, supporting high-frequency chain usage scenarios.

[0195] Figure 7 This is the second structural diagram of the transaction execution device based on blockchain provided by the present invention, such as Figure 7 As shown, the device includes: a receiving module 701, a second acquisition module 702 and a confirmation module 703, wherein:

[0196] The receiving module 701 is used for the root chain in the blockchain to receive the block header of the first block corresponding to the target transaction, where the first block is obtained by the first shard chain in the blockchain;

[0197] The second acquisition module 702 is used for the root chain to perform a packaging operation on the block header to obtain a second block;

[0198] The confirmation module 703 is used by the root chain to confirm that the first block is credible based on the second block, and to send a message for confirming that the first block is credible, so that the first shard chain determines to complete the execution process of the target transaction based on the message;

[0199] The blockchain includes the root chain and at least one shard chain.

[0200] Optionally, after the root chain is introduced into the blockchain, the root chain can be used to coordinate the shard chains, receive the block header of the first block generated by each shard chain, and package the block header of the first block into the second block. After the second block is packaged, after notifying each shard chain that the first block is finally confirmed to be credible based on the second block, the cross-chain part of the cross-chain transaction corresponding to the confirmed credible first block can be executed.

[0201] The blockchain-based transaction execution device provided by the present invention, by setting the blockchain to include a root chain and at least one shard chain, the shard chain obtains a first block for recording a target transaction, and the root chain packages the block header of the first block to obtain a second block for final confirmation of the target transaction, thereby achieving at least one shard chain being able to operate collaboratively under the coordination of the root chain, and further increasing the number of shard chains to increase the transaction throughput of the entire network, supporting high-frequency chain usage scenarios.

[0202] Optionally, the confirmation module includes:

[0203] In the case where the first block includes a forked block, the root chain filters out a target forked block from the forked block based on the second block corresponding to the forked block;

[0204] The root chain sends a message to confirm that the target forked block is credible.

[0205] The blockchain-based transaction execution device provided by the present invention, by setting the blockchain to include a root chain and at least one shard chain, the shard chain obtains a first block for recording a target transaction, the root chain packages the block header of the first block to obtain a second block for final confirmation of the target transaction, thereby achieving at least one shard chain being able to operate collaboratively under the coordination of the root chain, and then when the blockchain is attacked, the root chain and the shard need to be attacked at the same time to rewrite the confirmed block, which increases the difficulty of attack and thus provides higher security.

[0206] Figure 8 is a schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 8 As shown, the electronic device may include: a processor 810, a communication interface 820, a memory 830 and a communication bus 840, wherein the processor 810, the communication interface 820 and the memory 830 communicate with each other through the communication bus 840. The processor 810 may call the computer program in the memory 830 to execute the steps of the transaction execution method based on blockchain, for example, including:

[0207] The first shard chain in the blockchain obtains the first block corresponding to the target transaction;

[0208] The first shard chain transmits the block header of the first block to the root chain in the blockchain, so that the root chain performs a packaging operation on the block header to obtain a second block, and the second block is used by the root chain to confirm that the first block is credible and the root chain sends a message for confirming that the first block is credible;

[0209] The first shard chain determines, based on the message, an execution process for completing the target transaction;

[0210] The blockchain includes the root chain and at least one shard chain.

[0211] Or the steps of executing a blockchain-based transaction execution method, for example including:

[0212] The root chain in the blockchain receives the block header of the first block corresponding to the target transaction, where the first block is obtained by the first shard chain in the blockchain;

[0213] The root chain performs a packaging operation on the block header to obtain a second block;

[0214] The root chain confirms that the first block is credible based on the second block, and sends a message for confirming that the first block is credible, so that the first shard chain determines to complete the execution process of the target transaction based on the message;

[0215] The blockchain includes the root chain and at least one shard chain.

[0216] In addition, the logic instructions in the above-mentioned memory 830 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0217] On the other hand, the present invention further provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, and when the program instructions are executed by a computer, the computer can execute the blockchain-based transaction execution method provided by the above methods, the method comprising:

[0218] The first shard chain in the blockchain obtains the first block corresponding to the target transaction;

[0219] The first shard chain transmits the block header of the first block to the root chain in the blockchain, so that the root chain performs a packaging operation on the block header to obtain a second block, and the second block is used by the root chain to confirm that the first block is credible and the root chain sends a message for confirming that the first block is credible;

[0220] The first shard chain determines, based on the message, an execution process for completing the target transaction;

[0221] The blockchain includes the root chain and at least one shard chain.

[0222] Or execute the transaction execution method based on blockchain provided by the above methods, the method comprising:

[0223] The root chain in the blockchain receives the block header of the first block corresponding to the target transaction, where the first block is obtained by the first shard chain in the blockchain;

[0224] The root chain performs a packaging operation on the block header to obtain a second block;

[0225] The root chain confirms that the first block is credible based on the second block, and sends a message for confirming that the first block is credible, so that the first shard chain determines to complete the execution process of the target transaction based on the message;

[0226] The blockchain includes the root chain and at least one shard chain.

[0227] On the other hand, an embodiment of the present application further provides a processor-readable storage medium, wherein the processor-readable storage medium stores a computer program, wherein the computer program is used to enable the processor to execute the methods provided in the above embodiments, for example, including:

[0228] The first shard chain in the blockchain obtains the first block corresponding to the target transaction;

[0229] The first shard chain transmits the block header of the first block to the root chain in the blockchain, so that the root chain performs a packaging operation on the block header to obtain a second block, and the second block is used by the root chain to confirm that the first block is credible and the root chain sends a message for confirming that the first block is credible;

[0230] The first shard chain determines, based on the message, an execution process for completing the target transaction;

[0231] The blockchain includes the root chain and at least one shard chain.

[0232] Or executing the methods provided in the above embodiments, for example, including:

[0233] The root chain in the blockchain receives the block header of the first block corresponding to the target transaction, where the first block is obtained by the first shard chain in the blockchain;

[0234] The root chain performs a packaging operation on the block header to obtain a second block;

[0235] The root chain confirms that the first block is credible based on the second block, and sends a message for confirming that the first block is credible, so that the first shard chain determines to complete the execution process of the target transaction based on the message;

[0236] The blockchain includes the root chain and at least one shard chain.

[0237] The processor-readable storage medium can be any available medium or data storage device that can be accessed by the processor, including but not limited to magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc.), optical storage (such as CD, DVD, BD, HVD, etc.), and semiconductor storage (such as ROM, EPROM, EEPROM, non-volatile memory (NANDFLASH), solid-state drive (SSD)), etc.

[0238] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0239] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0240] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A transaction execution method based on blockchain, characterized in that: The method comprises: The first shard chain in the blockchain obtains the first block corresponding to the target transaction; The first shard chain transmits the block header of the first block to the root chain in the blockchain, so that the root chain performs a packaging operation on the block header and obtains a second block, the second block is used by the root chain to confirm that the first block is credible, and the root chain sends a message for confirming that the first block is credible; in the case where the first block includes a forked block, the second block corresponding to the forked block is used by the root chain to filter out a target forked block from the forked blocks, and the root chain sends a message for confirming that the target forked block is credible, and the target forked block is a credible block; The first shard chain determines, based on the message, an execution process for completing the target transaction; The blockchain includes the root chain and at least one shard chain.

2. The transaction execution method based on blockchain according to claim 1, characterized in that: The first shard chain determines, based on the message, an execution process for completing the target transaction, including: The first shard chain confirms that the first block is credible based on the message; The first shard chain calculates the address of the target execution node of the target transaction based on the address of the task initiation node of the target transaction; The first shard chain determines, based on the address of the target execution node, whether the target execution node is in the first shard chain; If the target execution node is in the first shard chain, executing the target transaction in the first shard chain; If the target execution node is not in the first shard chain, the second shard chain where the target execution node is located is determined to be the shard chain that executes the cross-chain part of the target transaction.

3. The transaction execution method based on blockchain according to claim 1, characterized in that: The first shard chain determines, based on the message, an execution process for completing the target transaction, including: The first shard chain confirms that the first block is credible based on the message; The first shard chain executes the target transaction.

4. The transaction execution method based on blockchain according to claim 1, characterized in that: The first shard chain in the blockchain obtains the first block corresponding to the target transaction, including: The first shard chain performs a first voting operation on the transaction requiring consensus to obtain a target transaction; The first shard chain performs a second voting operation on the proposal of the target transaction to obtain the first block.

5. A transaction execution method based on blockchain, characterized in that: The method comprises: The root chain in the blockchain receives the block header of the first block corresponding to the target transaction, where the first block is obtained by the first shard chain in the blockchain; The root chain performs a packaging operation on the block header to obtain a second block; The root chain confirms that the first block is credible based on the second block, and sends a message for confirming that the first block is credible, so that the first shard chain determines to complete the execution process of the target transaction based on the message; Wherein, the blockchain includes the root chain and at least one shard chain; The root chain confirms that the first block is credible based on the second block, and sends a message for confirming that the first block is credible, including: In the case where the first block includes a forked block, the root chain filters out a target forked block from the forked block based on the second block corresponding to the forked block, and the target forked block is a credible block; The root chain sends a message to confirm that the target forked block is credible.

6. A transaction execution device based on blockchain, characterized in that: The device comprises: A first acquisition module, used for the first shard chain in the blockchain to acquire the first block corresponding to the target transaction; A transmission module, configured for the first shard chain to transmit the block header of the first block to the root chain in the blockchain, so that the root chain performs a packaging operation on the block header and obtains a second block, the second block is used by the root chain to confirm that the first block is credible and the root chain sends a message for confirming that the first block is credible; in the case where the first block includes a forked block, the second block corresponding to the forked block is used by the root chain to filter out a target forked block from the forked blocks, and the root chain sends a message for confirming that the target forked block is credible, and the target forked block is a credible block; A determination module, configured for the first shard chain to determine an execution process for completing the target transaction based on the message; The blockchain includes the root chain and at least one shard chain.

7. A transaction execution device based on blockchain, characterized in that: The device comprises: A receiving module, configured to receive a block header of a first block corresponding to a target transaction from a root chain in a blockchain, where the first block is obtained from a first shard chain in the blockchain; A second acquisition module is used for the root chain to perform a packaging operation on the block header to obtain a second block; A confirmation module, used for the root chain to confirm that the first block is credible based on the second block, and to send a message for confirming that the first block is credible, so that the first shard chain determines to complete the execution process of the target transaction based on the message; Wherein, the blockchain includes the root chain and at least one shard chain; The confirmation module is also used for: In the case where the first block includes a forked block, the root chain filters out a target forked block from the forked block based on the second block corresponding to the forked block, and the target forked block is a credible block; The root chain sends a message to confirm that the target forked block is credible.

8. An electronic device comprising a processor and a memory storing a computer program, characterized in that: When the processor executes the computer program, it implements the steps of the blockchain-based transaction execution method described in any one of claims 1 to 4, or implements the steps of the blockchain-based transaction execution method described in claim 5.

9. A processor-readable storage medium, characterized in that: The processor-readable storage medium stores a computer program, and the computer program is used to enable the processor to execute the steps of the blockchain-based transaction execution method described in any one of claims 1 to 4, or to execute the steps of the blockchain-based transaction execution method described in claim 5.