Blockchain consensus method, block generation method, node and client
By sending transaction identifiers only during the endorsement phase of blockchain transactions for consensus ordering, and having the submitting node generate a complete block, the problem of redundant content transmission is solved, thus improving the performance and security of the blockchain system.
Patent Information
- Application Number
- CN202111140807.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-28
- Publication Date
- 2026-01-20
- Estimated Expiration
- 2041-09-28
AI Technical Summary
Existing blockchain transactions suffer from redundant content transmission issues, especially during the consensus phase where transaction content is broadcast and forwarded multiple times, resulting in high network overhead and impacting performance.
During the endorsement phase, only the transaction identifier is sent to the sorting node for consensus sorting, reducing content broadcasting during the consensus process; the sorting node generates the transaction identifier sorting result or the transaction identifier and block header, and the committing node generates the complete block after the transaction is verified, reducing unnecessary transaction content transmission.
It reduces the overhead of the blockchain system, improves performance and data security, and reduces the number of nodes required to transmit data and obtain complete transaction data.
Smart Images

Figure CN115883094B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of blockchain, in particular to a blockchain consensus method, a block generation method, a node and a client. BACKGROUND
[0002] The application mode of the blockchain is currently mainly divided into non-permission chain (public chain) and permission chain (alliance chain and private chain). The architecture model of the blockchain currently mainly has two kinds: ordering-execution model (OE model) and execution-ordering-verification model (EOV model), and the typical representative of the EOV model is Hyperledger Fabric.
[0003] The nodes of the Hyperledger Fabric are logically divided into ordering nodes and peer nodes, the ordering nodes are responsible for transaction ordering, and the peer nodes are responsible for transaction execution or endorsement and verification, and therefore, the peer nodes are functionally divided into endorser nodes and committer nodes.
[0004] However, the transaction process of the Hyperledger Fabric at least has the following problems:
[0005] 1. The elements of the transaction data required in the consensus phase are transaction identification and hash value, and the transaction content is only used to be packaged as a block body and is not modified or verified;
[0006] 2. The endorsement phase and the verification phase are completed by the peer nodes, and the endorser nodes and the committer nodes are partially or totally reused, and the required transaction content is consistent.
[0007] Transaction content needs to be obtained from other nodes in each phase, but part of the link does not really need content data, especially in the consensus phase, the transaction content will be broadcasted and forwarded multiple times in the process of executing the consensus mechanism, and therefore, great additional network overhead is brought, and when the transaction content data is more, the influence of the overhead on the performance of the blockchain is more obvious. SUMMARY
[0008] The purpose of the embodiments of the present application is to provide a blockchain consensus method, a block generation method, a node and a client to solve the problem of redundant content transmission in the existing blockchain transaction process.
[0009] In order to solve the above problems, the embodiments of the present application provide a blockchain consensus method applied to an ordering node, comprising:
[0010] Receiving transaction data or a transaction identification of the transaction data sent by a client; the transaction data comprises a transaction identification and transaction content;
[0011] According to the transaction identification, the transactions are consensus-sequenced to form a first block structure, the first block structure comprising: the sequenced transaction identification and a hash value, the hash value being calculated according to the sequenced transaction identification; or, according to the transaction data, the transactions are consensus-sequenced to form a second block structure, the second block structure comprising: a block header and the sequenced transaction identification.
[0012] The first block structure or the second block structure is sent to a submission node, so that the submission node performs transaction verification, and forms a complete block after the verification is completed.
[0013] According to the transaction data, the transactions are consensus-sequenced to form a second block structure, comprising:
[0014] According to the transaction identification, the transactions are consensus-sequenced to determine the sequenced transaction identification.
[0015] According to the sequenced transaction identification and the transaction content, the block header is calculated; the block header comprises a Merkle root.
[0016] The embodiment of the application further provides a block generation method applied to a submission node, comprising:
[0017] The first block structure or the second block structure formed by the consensus sequencing of the sequencing node is received, the first block structure comprising: the sequenced transaction identification and a hash value, the hash value being calculated according to the sequenced transaction identification; the second block structure comprising: a block header and the sequenced transaction identification.
[0018] The transaction data sent by the client is received, the transaction data comprising: a transaction identification and a transaction content.
[0019] According to the transaction data and the first block structure or the second block structure, transaction verification is performed, and a complete block is formed after the verification is completed.
[0020] According to the transaction data and the first block structure, transaction verification is performed, and a complete block is formed after the verification is completed, comprising:
[0021] After the integrity of the first block structure is verified, according to the first block structure and the transaction data, the transaction identification and the transaction content are matched, and transaction verification is performed.
[0022] After the verification is completed, the block header is calculated and the transactions are serialized based on the transaction identification sequencing of the first block structure, to form a complete block; the complete block comprising: a block header and a block body, the block body comprising each transaction data.
[0023] Wherein, after the verification is completed, the transaction identification sorting based on the first block structure is used for block header calculation and transaction serialization to form a complete block, including:
[0024] After the verification is completed, the transaction validity of each transaction data is marked; wherein, the valid transaction data is verified, and the invalid transaction data is not verified;
[0025] Based on the transaction identification sorting of the first block structure, the invalid transaction data is removed;
[0026] The block header calculation and transaction serialization are performed on the valid transaction data to form a complete block.
[0027] Wherein, according to the transaction data and the second block structure, the transaction verification is performed, and a complete block is formed after the verification is completed, including:
[0028] According to the second block structure and the transaction data, the matching of transaction identification and transaction content is performed;
[0029] The correctness of the matching result is verified by using the Merkle root in the block header of the second block structure, and the transaction verification is performed after the verification is passed;
[0030] After the verification is completed, the transaction identification sorting based on the second block structure is used for transaction serialization to form a complete block; the complete block includes: a block header and a block body, and the block body includes each transaction data.
[0031] Wherein, after the verification is completed, the transaction identification sorting based on the second block structure is used for transaction serialization to form a complete block, including:
[0032] After the verification is completed, the transaction validity of each transaction data is marked; wherein, the valid transaction data is verified, and the invalid transaction data is not verified;
[0033] Based on the transaction identification sorting of the second block structure, the invalid transaction data is removed;
[0034] The transaction serialization is performed on the valid transaction data to form a complete block.
[0035] The embodiment of the application further provides a block chain consensus and block generation method, which is applied to a client and includes:
[0036] According to the transaction endorsement result of the endorsement node feedback meeting the endorsement strategy, the transaction data is determined; the transaction data includes: transaction identification and transaction content;
[0037] The transaction data or the transaction identification is sent to a sorting node, so that the sorting node performs consensus sorting on the transaction;
[0038] Send the transaction data to a submission node, so that the submission node performs transaction verification based on the transaction data and the sorting result of the sorting node, and forms a complete block after verification is completed.
[0039] The sorting result of the sorting node includes:
[0040] The first block structure includes: sorted transaction identifier and hash value; the hash value is calculated according to the sorted transaction identifier;
[0041] Or,
[0042] The second block structure includes: block header and sorted transaction identifier.
[0043] The embodiment of the application further provides a sorting node, including a processor and a transceiver, the transceiver receives and sends data under the control of the processor, and the processor is used for executing the following operations:
[0044] Receive the transaction data or transaction identifier of the transaction data sent by the client; the transaction data includes: transaction identifier and transaction content;
[0045] According to the transaction identifier, the transaction is consensus sorted, and the first block structure is formed, the first block structure includes: sorted transaction identifier and transaction hash value, the hash value is calculated according to the sorted transaction identifier; or, according to the transaction data, the transaction is consensus sorted, and the second block structure is formed, the second block structure includes: block header and sorted transaction identifier;
[0046] Send the first block structure or the second block structure to the submission node, so that the submission node performs transaction verification, and forms a complete block after verification is completed.
[0047] The processor is further used for executing the following operations:
[0048] According to the transaction identifier, the transaction is consensus sorted, and the sorted transaction identifier is determined;
[0049] According to the sorted transaction identifier and the transaction content, the block header is calculated; the block header includes Merkel root.
[0050] The embodiment of the application further provides a submission node, including a processor and a transceiver, the transceiver receives and sends data under the control of the processor, and the processor is used for executing the following operations:
[0051] receive a first block structure or a second block structure formed by consensus sorting of a sorting node, the first block structure comprising: sorted transaction identifiers and hash values calculated according to the sorted transaction identifiers; and the second block structure comprising: a block header and sorted transaction identifiers;
[0052] receive transaction data sent by a client, the transaction data comprising: transaction identifiers and transaction contents;
[0053] perform transaction verification according to the transaction data and the first block structure or the second block structure, and form a complete block after verification is completed.
[0054] The processor is further configured to perform the following operations:
[0055] After verifying the integrity of the first block structure, match the transaction identifiers and the transaction contents according to the first block structure and the transaction data, and perform transaction verification;
[0056] After verification is completed, perform block header calculation and transaction serialization based on the transaction identifier sorting of the first block structure, and form a complete block; the complete block comprises: a block header and a block body, and the block body comprises each transaction data.
[0057] The processor is further configured to perform the following operations:
[0058] After verification is completed, mark the transaction validity of each transaction data; if verification is passed, the transaction data is valid transaction data, and if verification is not passed, the transaction data is invalid transaction data;
[0059] Based on the transaction identifier sorting of the first block structure, eliminate invalid transaction data;
[0060] Perform block header calculation and transaction serialization on the valid transaction data, and form a complete block.
[0061] The processor is further configured to perform the following operations:
[0062] Match the transaction identifiers and the transaction contents according to the second block structure and the transaction data;
[0063] Verify the correctness of the matching result by using the Merkle root in the block header of the second block structure, and perform transaction verification after verification is passed;
[0064] After verification is completed, perform transaction serialization based on the transaction identifier sorting of the second block structure, and form a complete block; the complete block comprises: a block header and a block body, and the block body comprises each transaction data.
[0065] The processor is further configured to perform the following operations:
[0066] After verification, mark the transaction validity of each transaction data; wherein, the valid transaction data is verified, and the invalid transaction data is not verified;
[0067] Based on the transaction identification sorting of the second block structure, the invalid transaction data is removed;
[0068] The valid transaction data is serialized for transaction, and a complete block is formed.
[0069] The embodiment of the application also provides a client, comprising a processor and a transceiver, the transceiver receives and sends data under the control of the processor, and the processor is used for executing the following operations:
[0070] According to the transaction endorsement result of the endorsement node feedback satisfying the endorsement strategy, the transaction data is determined; the transaction data comprises: transaction identification and transaction content;
[0071] The transaction data or the transaction identification is sent to the ordering node, so that the ordering node performs consensus ordering on the transaction;
[0072] The transaction data is sent to the committing node, so that the committing node performs transaction verification based on the transaction data and the ordering result of the ordering node, and forms a complete block after verification.
[0073] The ordering result of the ordering node comprises:
[0074] The first block structure comprises: the ordered transaction identification and a hash value, and the hash value is calculated according to the ordered transaction identification;
[0075] Or,
[0076] The second block structure comprises: a block header and the ordered transaction identification.
[0077] The embodiment of the application also provides a communication device, comprising a memory, a processor and a program stored in the memory and executable on the processor, wherein the processor executes the program to realize the block generation method as described above, or the processor executes the program to realize the block chain consensus method as described above, or the processor executes the program to realize the block chain consensus and block generation method as described above.
[0078] The embodiment of the application also provides a computer readable storage medium, which stores a computer program, the program is executed by the processor to realize the steps in the block generation method as described above, or the program is executed by the processor to realize the steps in the block chain consensus method as described above, or the program is executed by the processor to realize the steps in the block chain consensus and block generation method as described above.
[0079] The above technical solutions of the present application have at least the following beneficial effects:
[0080] In the blockchain consensus method, the block generation method, the node and the client of the embodiment of the present application, after the transaction is completed in the endorsement stage, the client only sends the transaction identifier to the ordering node for consensus ordering, and the content of multiple broadcast forwarding in the consensus process is reduced; when the block is packaged, the ordering node only generates a transaction identifier ordering result, or only generates a transaction identifier ordering result and a block header, and after the transaction verification is completed, the complete block is generated by the submitting node to complete the transaction accounting, thereby reducing unnecessary transaction content transmission, reducing the node number of obtaining complete transaction data on the one hand to reduce the additional cost and improve the performance of the blockchain system, and on the other hand to reduce data transmission, thereby improving data security. BRIEF DESCRIPTION OF DRAWINGS
[0081] Figure 1 A step flow chart showing the blockchain consensus and block generation method provided by the embodiment of the present application is shown in FIG. 1;
[0082] Figure 2 A step flow chart showing the blockchain consensus method provided by the embodiment of the present application is shown in FIG. 2;
[0083] Figure 3 A step flow chart showing the block generation method provided by the embodiment of the present application is shown in FIG. 3;
[0084] Figure 4 A principle schematic diagram of example one provided by the embodiment of the present application is shown in FIG. 4;
[0085] Figure 5 A principle schematic diagram of example two provided by the embodiment of the present application is shown in FIG. 5;
[0086] Figure 6 A principle schematic diagram of example three provided by the embodiment of the present application is shown in FIG. 6;
[0087] Figure 7 A structure schematic diagram of the submitting node provided by the embodiment of the present application is shown in FIG. 7;
[0088] Figure 8 A structure schematic diagram of the ordering node provided by the embodiment of the present application is shown in FIG. 8;
[0089] Figure 9 A structure schematic diagram of the client provided by the embodiment of the present application is shown in FIG. 9. DETAILED DESCRIPTION
[0090] In order to make the technical problems, technical solutions and advantages of the present application more clear, the following will be described in detail with reference to the drawings and specific embodiments.
[0091] In the embodiment of the application, the processing flow of the consensus sorting stage and / or the verification stage is optimized, the transmission data is simplified, and the performance and security of the blockchain system are improved. The method does not change the node classification and deployment method of the EOV model permission chain, and is convenient to apply.
[0092] In the embodiment of the application, after the endorsement stage is completed, the client sends only a transaction identifier uniquely identifying a transaction to a sorting node for transaction sorting. The sorting process is consistent with the original model, but the content of multiple broadcast forwarding in the consensus process is reduced. When a block is packaged, the sorting node only generates a transaction identifier sorting result or only generates a transaction identifier sorting result and a block header. After the transaction is verified by the submitting node, the submitting node packages the complete block to form a complete block, and then completes the transaction accounting. The block packaging can package all transactions or only package valid transactions.
[0093] As shown in Figure 1 The embodiment of the application provides a blockchain consensus and block generation method, applied to a client, including:
[0094] Step 101, determining transaction data according to the transaction endorsement result of the endorsement node satisfying the endorsement strategy; the transaction data includes a transaction identifier and transaction content;
[0095] Step 102, sending the transaction data or the transaction identifier to a sorting node, so that the sorting node performs consensus sorting on the transaction;
[0096] Step 103, sending the transaction data to a submitting node, so that the submitting node performs transaction verification based on the transaction data and the sorting result of the sorting node, and forms a complete block after the verification is completed.
[0097] For the client, in the embodiment of the application, the steps of the client constructing a transaction proposal and sending it to the endorsement node are consistent with the original model, which will not be expanded here. The transaction proposal includes a contract identifier, contract method and parameter information to be called in this transaction, and a client signature.
[0098] Optionally, the sorting result of the sorting node includes:
[0099] A first block structure, the first block structure includes: a sorted transaction identifier and a hash value, the hash value is calculated according to the sorted transaction identifier;
[0100] Or,
[0101] A second block structure, the second block structure includes: a block header and a sorted transaction identifier.
[0102] After the client collects the endorsement results that meet the endorsement policy, the transaction data is split into two parts: transaction identification (Tx ID) and transaction content (Payload).
[0103] In an optional embodiment, the client only sends the transaction identification to the ordering node, and does not send the transaction content; but the client sends the complete transaction data to the committing node.
[0104] The ordering node then uses the transaction identification to perform consensus ordering, and sends the ordering result and its hash value (i.e., the first block structure) to the committing node; the committing node verifies the integrity of the ordering result, obtains the corresponding transaction content using the transaction identification, and performs transaction verification, which is consistent with the original model; after the verification is completed, the committing node calculates the block header, packs it to form a complete block, and completes the transaction recording.
[0105] The complete block content and format generated by this method are the same as those of the original model. This method eliminates the redundant transmission of transaction content in the three stages of consensus: before consensus (Client->Orderer), during consensus (between consensus nodes), and after consensus (Orderer->Committer). At the same time, the ordering node cannot obtain the complete transaction content, which improves the security of the transaction.
[0106] In another optional embodiment, the client sends the complete transaction data to the ordering node and the committing node respectively;
[0107] The ordering node then parses the transaction identification, uses the transaction identification to perform consensus ordering on the transaction, calculates the block header according to the ordering result, and sends the block header and the ordered transaction identification (i.e., the second block structure, not the complete block) to the committing node; the committing node verifies the matching of the transaction content and the block header, and after completing all the transaction verifications specified in the original model, it calculates the block body from the transaction content, packs it with the block header to form a complete block, and completes the transaction recording.
[0108] The complete block content and format generated by this method are the same as those of the original model. This method eliminates the process of serializing the ordered transaction by the ordering node in the consensus stage, and the process of parsing the block structure and performing deserialization by the committing node in the verification stage, reducing the workload of the nodes and the network overhead of the block body sent to the committing node.
[0109] Further, when the committing node forms a complete block after verification, the block packing can optionally pack all transactions or only valid transactions.
[0110] For example, after the client collects the endorsement results meeting the endorsement policy, the consensus ordering process and the transaction verification process are consistent with the above embodiment, after the submitting node completes the transaction verification, the submitting node identifies the validity of the transaction, and the transaction is valid if the verification is passed, and the transaction is invalid if the verification is failed; the submitting node calculates the block header according to the valid transaction, generates a block with the valid transaction as the content, and completes the transaction accounting; and the submitting node notifies the client of the success / failure status of all transactions.
[0111] The complete block format generated by the method is the same as the original model, but since all the on-chain transactions are valid transactions, the size of the block body is related to the pass rate of the transaction verification, the higher the pass rate, the more valid transactions, and the larger the block body, but it will be smaller than the block body size under the original model. The method will effectively improve the end-to-end efficiency of the blockchain, reduce resource consumption, especially in the scenario where the transaction verification pass rate is low.
[0112] In summary, in the embodiment of the application, after the transaction is completed in the endorsement stage, the client only sends the transaction identifier to the ordering node for consensus ordering, so that the content of the multiple broadcast forwarding in the consensus process is reduced, on the one hand, the additional overhead is reduced, and the performance of the blockchain system is improved, on the other hand, the data transmission is reduced, the number of nodes obtaining complete transaction data is reduced, and the data security can be improved.
[0113] As shown in Figure 2 The embodiment of the application also provides a blockchain consensus method, applied to an ordering node, including:
[0114] Step 201, receiving transaction data or transaction identifier of the transaction data sent by the client; the transaction data includes: transaction identifier and transaction content;
[0115] Step 202, performing consensus ordering on the transaction according to the transaction identifier to form a first block structure, the first block structure including: ordered transaction identifier and hash value, the hash value being calculated according to the ordered transaction identifier; or performing consensus ordering on the transaction according to the transaction data to form a second block structure, the second block structure including: block header and ordered transaction identifier;
[0116] Step 203, sending the first block structure or the second block structure to the submitting node, so that the submitting node performs transaction verification, and forms a complete block after the verification is completed.
[0117] In the embodiment of the application, after the client (Client) collects the endorsement results meeting the endorsement policy, the transaction data is split into two parts: transaction identifier (Tx ID) and transaction content (Payload).
[0118] As an optional embodiment, the method further includes:
[0119] According to the sorted transaction identifier, the hash value is calculated and determined;
[0120] Alternatively,
[0121] The Merkel tree is constructed according to the sorted transaction identifier.
[0122] In an optional embodiment, the client only sends the transaction identifier to the ordering node, and the transaction content is not sent; but the client sends the complete transaction data to the committing node.
[0123] The ordering node then performs consensus ordering using the transaction identifier, and sends the ordering result and its hash value (i.e., the first block structure) to the committing node; the committing node verifies the integrity of the ordering result, obtains the corresponding transaction content using the transaction identifier, and performs transaction verification, which is consistent with the original model; after verification, the committing node calculates the block header and packs it to form a complete block, completing the transaction recording.
[0124] The complete block content and format generated by this method are the same as those of the original model. This method eliminates the redundant transmission of transaction content in the three stages of consensus: before consensus (Client->Orderer), during consensus (between consensus nodes), and after consensus (Orderer->Committer). At the same time, the ordering node cannot obtain the complete transaction content, improving the security of the transaction. And the network overhead of the consensus ordering process is significantly reduced, which helps to improve the end-to-end performance of the blockchain.
[0125] As another optional embodiment, the consensus ordering according to the transaction data to form a second block structure comprises:
[0126] According to the transaction identifier, the transaction is consensus-ordered to determine the sorted transaction identifier;
[0127] According to the sorted transaction identifier and the transaction content, the block header is calculated; the block header includes the Merkel root.
[0128] In another optional embodiment, the client sends the complete transaction data to the ordering node and the committing node respectively;
[0129] The ordering node then parses the transaction identifier, performs consensus ordering on the transaction using the transaction identifier, calculates the block header according to the ordering result, and sends the block header and the sorted transaction identifier (i.e., the second block structure, not the complete block) to the committing node; the committing node verifies the matching of the transaction content and the block header, and after completing all the transaction verifications specified in the original model, it calculates the block body from the transaction content, packs it with the block header to form a complete block, and completes the transaction recording.
[0130] The complete block content and format generated by the method are the same as the original model. The method saves the process of serializing the sorted transactions by the sorting node in the consensus stage and the process of parsing the block structure and deserializing by the submitting node in the verification stage, reduces the workload of the node, and also reduces the network overhead of the block body sent to the submitting node.
[0131] Further, the submitting node can select to pack all transactions or only valid transactions when forming the complete block after verification.
[0132] For example, after the client collects the endorsement results meeting the endorsement policy, the consensus sorting process and the transaction verification process are consistent with the above embodiment. After the submitting node completes the transaction verification, the submitting node identifies the validity of the transaction. If the verification is passed, the transaction is valid, and if the verification is failed, the transaction is invalid. The submitting node calculates the block header according to the block packing rule for the valid transaction, generates a block with the valid transaction as the content, and completes the transaction accounting. The submitting node notifies the client of the success / failure status of all transactions.
[0133] The format of the complete block generated by the method is the same as the original model, but since all the on-chain transactions are valid transactions, the size of the block body is related to the verification pass rate of the transaction. The higher the pass rate is, the more valid transactions there are, and the larger the block body is, but it will be smaller than the block body size in the original model. The method will effectively improve the end-to-end efficiency of the blockchain and reduce resource consumption, especially in the scenario where the transaction verification pass rate is low.
[0134] In summary, in the embodiment of the application, after the transaction is completed in the endorsement stage, the client only sends the transaction identifier to the sorting node for consensus sorting, so that the content of the multiple broadcast forwarding in the consensus process is reduced. In the block packing, the sorting node only generates a transaction identifier sorting result or only generates a transaction identifier sorting result and a block header. After the transaction verification is completed, the submitting node generates a complete block, thereby reducing unnecessary transmission of transaction content, reducing the extra overhead and improving the performance of the blockchain system on the one hand, and reducing data transmission and reducing the number of nodes obtaining complete transaction data, which can improve data security on the other hand.
[0135] As shown in FIG. 1, Figure 3 The embodiment of the application provides a block generation method applied to a submitting node, which comprises the following steps:
[0136] In step 301, a first block structure or a second block structure formed by a sorting node through consensus sorting is received. The first block structure comprises sorted transaction identifiers and hash values, and the hash values are calculated according to the sorted transaction identifiers. The second block structure comprises a block header and sorted transaction identifiers.
[0137] In step 302, transaction data sent by a client is received. The transaction data comprises transaction identifiers and transaction content.
[0138] In step 303, according to the transaction data and the first block structure or the second block structure, transaction verification is performed, and a complete block is formed after the verification is completed.
[0139] In the embodiment of the application, after the client collects the endorsement result meeting the endorsement strategy, the transaction data is split into two parts, a transaction identifier (Tx ID) and a transaction content (Payload).
[0140] In an optional embodiment, the client sends only the transaction identifier to the ordering node, and does not send the transaction content; but the client sends the complete transaction data to the committing node; then the ordering node performs consensus ordering by using the transaction identifier, and sends the ordering result and a hash value (i.e., the first block structure) to the committing node.
[0141] In another optional embodiment, the client sends the complete transaction data to the ordering node and the committing node respectively; then the ordering node parses the transaction identifier, performs consensus ordering on the transaction by using the transaction identifier, calculates a block header according to the ordering result, and sends the block header and the ordered transaction identifier (i.e., the second block structure, not the complete block) to the committing node.
[0142] Further, when the committing node forms the complete block after the verification is completed, the block packaging can select to package all transactions or only valid transactions.
[0143] For the first block structure, step 303 includes:
[0144] After verifying the integrity of the first block structure, the transaction identifier and the transaction content are matched according to the first block structure and the transaction data, and transaction verification is performed;
[0145] After the verification is completed, the block header calculation and transaction serialization are performed based on the transaction identifier ordering of the first block structure, and a complete block is formed; the complete block includes a block header and a block body, and the block body includes each transaction data.
[0146] If only valid transactions are packaged, the block header calculation and transaction serialization are performed based on the transaction identifier ordering of the first block structure, and a complete block is formed, including:
[0147] After the verification is completed, the transaction validity of each transaction data is marked; wherein, the valid transaction data is verified, and the invalid transaction data is not verified;
[0148] Based on the transaction identifier ordering of the first block structure, the invalid transaction data is removed;
[0149] The block header calculation and transaction serialization are performed on the valid transaction data, and a complete block is formed.
[0150] For the second block structure, step 303 includes:
[0151] Based on the second block structure and the transaction data, the transaction identifier and transaction content are matched;
[0152] The Merkle root in the block header of the second block structure is used to verify the correctness of the matching result. If the verification is successful, the transaction verification is executed.
[0153] After verification, the transactions are serialized based on the transaction identifiers sorted according to the second block structure to form a complete block; the complete block includes: a block header and a block body, and the block body includes the serialized values of each transaction data.
[0154] If only valid transactions are packaged, after the verification is completed, the transactions are serialized based on the transaction identifiers sorted according to the second block structure to form a complete block, including:
[0155] After verification, the validity of each transaction is marked; where valid transaction data is marked as valid and invalid transaction data is marked as invalid.
[0156] Sorting transactions based on their identifiers in the second block structure and removing invalid transaction data;
[0157] Valid transaction data is serialized to form a complete block.
[0158] In summary, in the block packaging embodiments of the present invention, the sorting node only generates the transaction identifier sorting result, or only generates the transaction identifier sorting result and block header. After the transaction verification is completed, the submitting node generates a complete block for all transactions or valid transactions to complete the transaction accounting. This reduces unnecessary transaction content transmission, thereby reducing additional overhead and improving the performance of the blockchain system. On the other hand, it reduces data transmission and the number of nodes that obtain complete transaction data, which can improve data security.
[0159] To more clearly describe the blockchain consensus and block generation method provided in the embodiments of the present invention, three examples are provided below.
[0160] Example 1: Transaction identifier consensus ordering, block packaging during the verification phase, such as... Figure 4 As shown:
[0161] The data sent by the client to the sorting node includes: a transaction identifier (Tx ID), which uniquely identifies a transaction; and a client signature, which ensures the integrity of the data and prevents it from being tampered with.
[0162] The data sent by the client to the submitting node is the complete transaction endorsement result, i.e., the transaction data, including the transaction identifier and the transaction content.
[0163] After consensus sorting, the formed block structure mainly includes sorted transaction identification and its hash value. The hash value calculation method is not limited, for example, the hash value of the sorted transaction identification can be calculated, or the transaction identification is constructed into a Merkle tree according to the sorted order.
[0164] The first block structure is sent to the submitting node. After verifying the integrity of the first block structure, the submitting node matches the transaction identification with the transaction content according to the transaction sorting of the first block structure, and performs the VSCC verification and other verification processes. The verification items and methods are consistent with the original model. After verification, the block header is calculated and the transaction is serialized based on the sorting of the first block structure to form a complete block.
[0165] Example two, only the block header and transaction identification are sent after consensus sorting, and the block body is calculated and packaged into a block in the verification stage, as shown in Figure 5
[0166] The client sends the transaction endorsement result (i.e. transaction data) to the sorting node and the submitting node at the same time. The data structure is the same as the endorsement result in the original model.
[0167] After consensus sorting, the formed second block structure mainly includes the block header and the sorted transaction identification.
[0168] The second block structure is sent to the submitting node. The submitting node matches the transaction identification with the transaction content according to the transaction sorting of the second block structure using the transaction data sent by the client, and verifies the correctness of the matching result using the Merkle root (MerkleRoot) in the block header (MerkleRoot is formed by hash calculation of the transactions in this block). The block verification process is performed, the verification items and methods are consistent with the original model, and after verification, the transaction is serialized based on the second block structure to form a complete block.
[0169] Example three, on the basis of example one, only valid transactions are packaged, as shown in Figure 6
[0170] The data sent by the client to the sorting node includes: transaction identification (Tx ID), which can uniquely identify a transaction; and client signature, which can ensure the integrity and non-tampering of the data.
[0171] The data sent by the client to the submitting node is the complete transaction endorsement result, i.e. transaction data, including transaction identification and transaction content.
[0172] After consensus sorting, the formed block structure mainly includes sorted transaction identifiers and hash values thereof. The hash value calculation method is not limited, for example, the hash value of the sorted transaction identifier can be calculated, or the transaction identifier is constructed into a Merkle tree according to the sorted order of the transaction identifier.
[0173] The first block structure is sent to a submission node, the submission node verifies the integrity of the first block structure, and according to the transaction sorting of the first block structure, the transaction data sent by the client is used to match the transaction identifier and the transaction content, and a VSCC verification and other verification processes are performed, the verification items and methods are consistent with the original model, and after the verification is completed, the transaction validity is marked, and if the verification is passed, it is valid, and if the verification is not passed, it is invalid. Classify transactions by validity, remove invalid transactions based on first block structure sorting, and perform block header calculation and transaction serialization for valid transactions to form a complete block structure. The structure of the verification node packaged block (complete block) is consistent with the block structure under the original model, but due to the removal of part of the invalid transactions, the block body is reduced.
[0174] In summary, in the embodiment of the application, after the transaction is completed in the endorsement stage, the client only sends the transaction identifier to the sorting node for consensus sorting, so that the content of the multiple broadcast forwarding in the consensus process is reduced; during block packaging, the sorting node only generates a transaction identifier sorting result, or only generates a transaction identifier sorting result and a block header, and after the transaction verification is completed, the submission node generates a complete block to complete the transaction accounting, thereby reducing unnecessary transaction content transmission, reducing the node number of obtaining complete transaction data, and improving data security.
[0175] As shown in Figure 7 The embodiment of the application also provides a sorting node, which comprises a processor 700 and a transceiver 710, the transceiver 710 receives and sends data under the control of the processor 700, and the processor 700 is used for executing the following operations:
[0176] Receiving transaction data or transaction identifiers of transaction data sent by a client; the transaction data comprises: transaction identifiers and transaction contents;
[0177] According to the transaction identifier, the transaction is consensus sorted to form a first block structure, the first block structure comprises: sorted transaction identifiers and hash values, and the hash values are calculated according to the sorted transaction identifiers; or according to the transaction data, the transaction is consensus sorted to form a second block structure, the second block structure comprises: a block header and sorted transaction identifiers;
[0178] The first block structure or the second block structure is sent to a submission node to enable the submission node to perform transaction verification and form a complete block after the verification is completed.
[0179] As an optional embodiment, the processor is further configured to perform the following operation:
[0180] The transactions are consensus-ordered according to the transaction identifiers, and the ordered transaction identifiers are determined.
[0181] The block header is calculated according to the ordered transaction identifiers and the transaction contents, and the block header includes a Merkle root.
[0182] In the embodiment of the application, when the block is packaged, the ordering node only generates a transaction identifier ordering result or only generates a transaction identifier ordering result and a block header, and a complete block is generated by the submission node after the transaction verification is completed, and the transaction is recorded, thereby reducing unnecessary transaction content transmission, reducing the additional cost on the one hand, improving the performance of the block chain system, and reducing data transmission and the number of nodes obtaining complete transaction data on the other hand, and the data security can be improved.
[0183] It should be noted that the ordering node provided in the embodiment of the application is a node capable of performing the above-mentioned block chain consensus method, and all embodiments of the above-mentioned block chain consensus method are applicable to the node, and the same or similar beneficial effects can be achieved.
[0184] As shown in Figure 8 The embodiment of the application further provides a submission node, which comprises a processor 800 and a transceiver 810, the transceiver 810 receives and sends data under the control of the processor 800, and the processor 800 is configured to perform the following operations:
[0185] The first block structure or the second block structure formed by the ordering node through consensus ordering is received, the first block structure comprises ordered transaction identifiers and hash values, and the hash values are calculated according to the ordered transaction identifiers; and the second block structure comprises a block header and ordered transaction identifiers.
[0186] The transaction data sent by the client is received, and the transaction data comprises transaction identifiers and transaction contents.
[0187] According to the transaction data and the first block structure or the second block structure, the transaction is verified, and a complete block is formed after the verification is completed.
[0188] As an optional embodiment, the processor is further configured to perform the following operation:
[0189] After verifying the integrity of the first block structure, the transaction identification and the transaction content are matched according to the first block structure and the transaction data, and the transaction verification is performed;
[0190] After the verification is completed, the block header calculation and the transaction serialization are performed based on the transaction identification sorting of the first block structure, and a complete block is formed; the complete block includes a block header and a block body, and the block body includes each transaction data.
[0191] As an optional embodiment, the processor is further configured to perform the following operation:
[0192] After the verification is completed, the transaction validity of each transaction data is marked; if the verification is passed, the transaction data is valid transaction data, and if the verification is not passed, the transaction data is invalid transaction data;
[0193] Based on the transaction identification sorting of the first block structure, the invalid transaction data is removed;
[0194] The block header calculation and the transaction serialization are performed on the valid transaction data, and a complete block is formed.
[0195] As an optional embodiment, the processor is further configured to perform the following operation:
[0196] According to the second block structure and the transaction data, the transaction identification and the transaction content are matched;
[0197] The correctness of the matching result is verified by using the Merkle root in the block header of the second block structure, and the transaction verification is performed after the verification is passed;
[0198] After the verification is completed, the transaction serialization is performed based on the transaction identification sorting of the second block structure, and a complete block is formed; the complete block includes a block header and a block body, and the block body includes each transaction data.
[0199] As an optional embodiment, the processor is further configured to perform the following operation:
[0200] After the verification is completed, the transaction validity of each transaction data is marked; if the verification is passed, the transaction data is valid transaction data, and if the verification is not passed, the transaction data is invalid transaction data;
[0201] Based on the transaction identification sorting of the second block structure, the invalid transaction data is removed;
[0202] The transaction serialization is performed on the valid transaction data, and a complete block is formed.
[0203] In the embodiment of the present application, after the transaction is completed in the endorsement stage, the ordering node only generates a transaction identification sorting result or only generates a sorting result of the transaction identification and a block header, and a complete block is generated by the submitting node after the transaction verification is completed, so that the transaction is recorded, thereby reducing unnecessary transaction content transmission, reducing additional overhead on the one hand to improve the performance of the blockchain system, and reducing data transmission and reducing the number of nodes obtaining complete transaction data on the other hand, thereby improving data security.
[0204] It should be noted that the submitting node provided in the embodiment of the present application is a node capable of performing the above block generation method, and all embodiments of the above block generation method are applicable to the node and can achieve the same or similar beneficial effects.
[0205] As shown in Figure 9 The embodiment of the present application also provides a client, which comprises a processor 900 and a transceiver 910, the transceiver 910 receives and sends data under the control of the processor 900, and the processor 900 is used for performing the following operations:
[0206] According to the transaction endorsement result of the endorsement node satisfying the endorsement strategy, the transaction data is determined; the transaction data comprises a transaction identification and a transaction content;
[0207] The transaction data or the transaction identification is sent to an ordering node, so that the ordering node performs consensus sorting on the transaction;
[0208] The transaction data is sent to a submitting node, so that the submitting node performs transaction verification based on the transaction data and the sorting result of the ordering node, and forms a complete block after the verification is completed.
[0209] As an optional embodiment, the sorting result of the ordering node comprises:
[0210] A first block structure, the first block structure comprises a sorted transaction identification and a hash value, and the hash value is calculated according to the sorted transaction identification;
[0211] Or,
[0212] A second block structure, the second block structure comprises a block header and a sorted transaction identification.
[0213] In the embodiment of the present application, after the transaction is completed in the endorsement stage, the client only sends the transaction identification to the ordering node for consensus sorting, so that the content of the multiple broadcast forwarding in the consensus process is reduced, on the one hand, the additional overhead is reduced to improve the performance of the blockchain system, and on the other hand, the data transmission is reduced, the number of nodes obtaining complete transaction data is reduced, and the data security is improved.
[0214] It should be noted that the client provided by the embodiment of the present application is a node capable of performing the blockchain consensus and block generation method, and all embodiments of the blockchain consensus and block generation method are applicable to the node, and can achieve the same or similar beneficial effects.
[0215] The embodiment of the present application also provides a communication device, which is a submitting node or a sorting node or a client, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements each process in the block generation method or the blockchain consensus method or the blockchain consensus and block generation method embodiment and can achieve the same technical effects when executing the program, and details are not repeated here to avoid repetition.
[0216] The embodiment of the present application also provides a computer readable storage medium having a computer program stored thereon, wherein the program is executed by a processor to implement each process in the block generation method or the blockchain consensus method or the blockchain consensus and block generation method embodiment and can achieve the same technical effects, and details are not repeated here to avoid repetition. The computer readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0217] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system or a computer program product. Therefore, the present application can be in the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Moreover, the present application can be in the form of a computer program product implemented on one or more computer readable storage media (including but not limited to disk storage and optical storage, etc.) containing computer usable program code.
[0218] The present application is described with reference to flowcharts and / or block diagrams according to the method, device (system) and computer program product of the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of the flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing devices to produce a machine, so that the instructions executed by the computer or other programmable data processing devices produce a device that implements the functions specified in the flowcharts and / or block diagrams. Figure 1 The apparatus for implementing each flow or multiple flows and / or one block or multiple blocks specified in the functions.
[0219] These computer program instructions can also be stored in a computer readable medium that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer readable medium produce an article of manufacture including instructions which implement the flow Figure 1 The flow or flows and / or blocks Figure 1 The flow or flows and / or blocks
[0220] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the flow Figure 1 The flow or flows and / or blocks Figure 1 The flow or flows and / or blocks
[0221] The above description is the preferred embodiment of the application. It is to be understood that the above description is intended to be illustrative and not restrictive. Many changes and modifications can come to mind to one skilled in the art having the benefit of the teachings of the present disclosure, and it is intended to cover all such modifications and changes as fall within the scope of the claims.
Claims
1. A blockchain consensus method applied to sorting nodes, characterized in that, include: The sorting node receives the transaction identifier of the transaction data sent by the client; wherein, the client does not send the transaction content of the transaction data to the sorting node; the client sends the transaction data to the submission node; the transaction data includes: transaction identifier and transaction content; The sorting node performs consensus sorting of transactions based on the transaction identifier to form a first block structure. The first block structure includes: sorted transaction identifiers and hash values, wherein the hash values are calculated based on the sorted transaction identifiers. The sorting node sends the first block structure to the committing node, so that the committing node can verify the integrity of the sorting result based on the first block structure, obtain the corresponding transaction content from the transaction data sent by the client using the transaction identifier, perform transaction verification, and form a complete block after verification.
2. A block generation method, applied to a commit node, characterized in that, include: The submitting node receives the first block structure formed by the sorting node through consensus sorting. The first block structure includes: sorted transaction identifiers and hash values, wherein the hash values are calculated based on the sorted transaction identifiers; wherein the first block structure is formed by the sorting node through consensus sorting based on the transaction identifiers sent by the client. The submitting node receives transaction data sent by the client, the transaction data including: transaction identifier and transaction content; The submitting node verifies the integrity of the sorting result based on the structure of the first block, retrieves the corresponding transaction content from the transaction data sent by the receiving client using the transaction identifier, verifies the transaction, and forms a complete block after verification.
3. The method according to claim 2, characterized in that, Based on the integrity of the sorting result verified by the first block structure, the corresponding transaction content is obtained from the transaction data sent by the receiving client using the transaction identifier, transaction verification is performed, and a complete block is formed after verification, including: After verifying the integrity of the first block structure, the transaction identifier and transaction content are matched according to the first block structure and the transaction data, and transaction verification is performed. After verification, the block header is calculated and the transactions are serialized based on the transaction identifiers sorted according to the first block structure to form a complete block; the complete block includes: a block header and a block body, and the block body includes each transaction data.
4. The method according to claim 3, characterized in that, After verification, the block header is calculated and transactions are serialized based on the transaction identifiers sorted according to the first block structure to form a complete block, including: After verification, the validity of each transaction is marked; where valid transaction data is marked as valid and invalid transaction data is marked as invalid. Sorting transactions based on their identifiers in the first block structure and removing invalid transaction data; Valid transaction data is used to calculate block headers and serialize transactions to form complete blocks.
5. A blockchain consensus and block generation method, applied to a client, characterized in that, include: Based on the endorsement results of transactions that meet the endorsement strategy, as reported by the endorsement nodes, determine the transaction data. The transaction data includes: transaction identifier and transaction content; The transaction identifier is sent to the sorting node, so that the sorting node performs consensus sorting of transactions based on the transaction identifier to form a first block structure and sends it to the commit node; the first block structure includes: sorted transaction identifiers and hash values, wherein the hash value is calculated based on the sorted transaction identifiers; wherein, the client does not send the transaction content of the transaction data to the sorting node. The transaction data is sent to the submission node so that the integrity of the sorting result is verified according to the first block structure. The corresponding transaction content is obtained from the transaction data sent by the client using the transaction identifier, the transaction is verified, and a complete block is formed after the verification is completed.
6. A sorting node, comprising a processor and a transceiver, wherein the transceiver receives and transmits data under the control of the processor, characterized in that, The processor is used to perform the following operations: The system receives a transaction identifier from transaction data sent by a client; wherein the client does not send the transaction content of the transaction data to the sorting node; the client sends the transaction data to the submission node; the transaction data includes: a transaction identifier and transaction content; Transactions are sorted according to the transaction identifiers to form a first block structure. The first block structure includes: sorted transaction identifiers and transaction hash values, wherein the hash values are calculated based on the sorted transaction identifiers. The first block structure is sent to the commit node, so that the commit node can verify the integrity of the sorting result based on the first block structure, obtain the corresponding transaction content from the transaction data sent by the client using the transaction identifier, perform transaction verification, and form a complete block after verification.
7. A submission node, comprising a processor and a transceiver, wherein the transceiver receives and transmits data under the control of the processor, characterized in that, The processor is used to perform the following operations: The receiving sorting node forms a first block structure through consensus sorting. The first block structure includes: sorted transaction identifiers and hash values, wherein the hash values are calculated based on the sorted transaction identifiers; wherein the first block structure is formed by the sorting node through consensus sorting based on the transaction identifiers sent by the client. Receive transaction data sent by the client, the transaction data including: transaction identifier and transaction content; Based on the integrity of the sorting result of the first block structure verification, the corresponding transaction content is obtained from the transaction data sent by the receiving client using the transaction identifier, the transaction is verified, and a complete block is formed after the verification is completed.
8. The submission node according to claim 7, characterized in that, The processor is also used to perform the following operations: After verifying the integrity of the first block structure, the transaction identifier and transaction content are matched according to the first block structure and the transaction data, and transaction verification is performed. After verification, the block header is calculated and transactions are serialized based on the transaction identifiers sorted according to the first block structure to form a complete block; The complete block includes a block header and a block body, the block body of which includes all transaction data.
9. The submission node according to claim 8, characterized in that, The processor is also used to perform the following operations: After verification, the validity of each transaction is marked; where valid transaction data is marked as valid and invalid transaction data is marked as invalid. Sorting transactions based on their identifiers in the first block structure and removing invalid transaction data; Valid transaction data is used to calculate block headers and serialize transactions to form complete blocks.
10. A client comprising a processor and a transceiver, the transceiver receiving and transmitting data under the control of the processor, characterized in that, The processor is used to perform the following operations: Based on the endorsement results of transactions that meet the endorsement strategy, as fed back by the endorsement nodes, the transaction data is determined; the transaction data includes: transaction identifier and transaction content. The transaction identifier is sent to the sorting node, so that the sorting node performs consensus sorting of transactions based on the transaction identifier to form a first block structure and sends it to the commit node; the first block structure includes: sorted transaction identifiers and hash values, wherein the hash value is calculated based on the sorted transaction identifiers; wherein, the client does not send the transaction content of the transaction data to the sorting node. The transaction data is sent to the submission node so that the integrity of the sorting result is verified according to the first block structure. The corresponding transaction content is obtained from the transaction data sent by the client using the transaction identifier, the transaction is verified, and a complete block is formed after the verification is completed.
11. A communication device, comprising a memory, a processor, and a program stored in the memory and executable on the processor; characterized in that, When the processor executes the program, it implements the blockchain consensus method as described in claim 1; or when the processor executes the program, it implements the block generation method as described in any one of claims 2-4; or when the processor executes the program, it implements the blockchain consensus and block generation method as described in claim 5.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps in the blockchain consensus method as described in claim 1; or, when the program is executed by the processor, it implements the steps in the block generation method as described in any one of claims 2-4; or, when the program is executed by the processor, it implements the steps in the blockchain consensus and block generation method as described in claim 5.
Citation Information
Patent Citations
Transaction processing method of block chain network and blockchain network
CN110544095A
Block chain data management method and device and storage medium
CN112883015A