A transaction concurrency control method and system based on Fabric
By checking transaction conflicts in the simulation and sorting stages of Fabric's transaction processing, and determining and feeding back invalid transactions in advance, the problems of resource waste and low efficiency in the existing technology are solved, concurrent transaction control is achieved, and transaction processing efficiency is improved.
Patent Information
- Application Number
- CN202111483185.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-07
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2041-12-07
AI Technical Summary
Fabric completely places conflict checking in the verification step during transaction processing, resulting in invalid transactions discovered during the simulation and sorting stages unable to be fed back in time, resulting in a waste of system resources and low efficiency of transaction on-chain.
In the simulation stage, the verification key is used to check whether the transaction conflicts with the transaction that has entered the verification stage, and in the sorting stage, the version number conflict of the transaction in the same block is checked to determine and feedback invalid transactions in advance to achieve concurrency in the simulation, sorting and verification stages. control.
It effectively saves system resources, improves transaction feedback speed, and achieves true concurrent transaction control, reduces the processing of invalid transactions, and improves the efficiency of transaction on-chain.
Smart Images

Figure CN114240434B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of blockchain data processing, and in particular to a transaction concurrency control method and system based on Fabric. Background Art
[0002] Hyperledger is an important architecture in the use of blockchain, in which Fabric uses a transaction processing model based on simulation-sorting-verification-commitment to complete the entire process from transaction initiation to final writing into the ledger. Although Fabric can ensure accurate execution of smart contracts and meet the requirements of result certainty, it can also fully utilize the parallel computing capabilities of current high-performance processing chips through parallel processing.
[0003] However, because Fabric places conflict checking entirely in the verification step, invalid transactions that cannot be packaged into blocks that are discovered during the simulation and sorting stages can only be confirmed and fed back during the verification stage, causing a large amount of system resources to be wasted on processing invalid transactions, affecting the efficiency of transaction on-chain processing. Invalid transactions cannot be fed back to users in a timely manner, making it impossible for users to correct transaction information errors in the first place. Summary of the invention
[0004] In order to address the deficiencies of the prior art, the present invention proposes a transaction concurrency control method and system based on Fabric, which determines whether the current transaction is an invalid transaction by checking the key value of the attached verification key and the block to which it belongs in the simulation stage, and determines whether the current transaction is an invalid transaction by additionally checking whether different transactions in the same block use the same version of the verification key in the sorting stage, thereby achieving invalid transactions and feedback in the simulation and sorting stages before verification, thereby achieving early termination of invalid transactions, effectively saving system resources, and realizing true concurrent transaction control in the three stages of simulation, sorting and verification.
[0005] To achieve the above objectives, the technical solutions adopted by the present invention include:
[0006] A transaction concurrency control method based on Fabric, characterized by comprising:
[0007] S1. Establish a set of verification keys involved in the transaction process, wherein the verification key includes a key value and version number information, wherein the version number information includes the current version number, the transaction ID for executing the update, and the block ID for storing the transaction;
[0008] S2. During the simulation phase, use the verification key to check whether the transaction currently being simulated conflicts with any transaction that has entered the verification phase, and stop simulating the conflicting transaction;
[0009] S3. In the sorting phase, use the verification key to check whether there are conflicts between multiple transactions in the same block currently being sorted, and stop sorting transactions with conflicts;
[0010] Wherein, step S2 further comprises the following sub-steps:
[0011] S21, identifying the verification key read by the transaction currently being simulated;
[0012] S22, comparing the block ID of the verification key with the latest verified block ID;
[0013] S23. If the block ID of the verification key is greater than the block ID of the latest verified block, it is determined that there is a conflict between the currently executed simulated transaction and any transaction that has entered the verification stage; otherwise, it is determined that there is no conflict between the currently executed simulated transaction and any transaction that has entered the verification stage;
[0014] S24, stop simulating the conflicting transaction and provide feedback to the transaction initiator to resubmit the transaction;
[0015] S25, submitting the simulated transactions to the sorting stage;
[0016] Step S3 further comprises the sub-steps of:
[0017] S31, identifying multiple transactions in the same block that read the same verification key;
[0018] S32. Verify whether the same verification key read by multiple exchanges has the same version number information;
[0019] S33. If the same verification key read by multiple exchanges has different version number information, it is determined that there is a conflict between the multiple transactions in the same block currently being sorted; otherwise, it is determined that there is no conflict between the multiple transactions in the same block currently being sorted;
[0020] S34. For multiple transactions that are in conflict, stop sorting the corresponding transactions with later version number information, and feedback the transaction initiator to resubmit the transaction;
[0021] S35. Submit the sorted transactions to the verification stage.
[0022] Furthermore, the method further comprises:
[0023] S4. Update the key value and version number information of the verification key according to the transaction request.
[0024] Furthermore, the version number information of the update verification key includes modifying the transaction ID for executing the update and the block ID for storing the transaction, and generating a new current version number.
[0025] Furthermore, the step S4 further comprises the following sub-steps:
[0026] S41. Verify whether the transaction signature is legal. If the verification is illegal, feedback is given to the transaction initiator to resubmit the transaction;
[0027] S42. Further verify whether the transaction content is legal for the transaction that has passed the signature verification. If the verification is illegal, the transaction initiator is fed back to resubmit the transaction;
[0028] S43. For transactions that pass content verification, update the key value and version number information of the verification key according to the transaction request.
[0029] Furthermore, the method further comprises:
[0030] When a transaction includes both requests to read and update the verification key, steps S2 and S3 are executed first to verify the read request of the transaction, and for the transaction verified by the read request, the key value and version number information of the verification key are updated according to the update request of the transaction.
[0031] Further, the sub-step S25 includes:
[0032] After the transaction simulation is successfully executed, a response value and the result of reading the verification key are generated, and the result is endorsed and fed back to the transaction initiator.
[0033] Further, the sub-step S35 includes:
[0034] Sort the unpackaged transactions to generate new blocks, and broadcast the new blocks to other nodes for verification.
[0035] The present invention also relates to a Fabric-based transaction concurrency control system, which is characterized by comprising:
[0036] Client, used to submit transaction requests and receive feedback results;
[0037] A verification key establishment module, used to establish a set of verification keys involved in the transaction process;
[0038] The transaction simulation module is used to use the verification key to verify whether the transaction currently being simulated conflicts with any transaction that has entered the verification stage, and to simulate the transactions that have passed the verification;
[0039] The transaction sorting module is used to use the verification key to verify whether there are conflicts between multiple transactions in the same block currently being sorted, and to sort the transactions that have passed the verification;
[0040] The transaction verification module is used to verify the new blocks generated by the transaction.
[0041] The present invention also relates to a computer-readable storage medium, characterized in that a computer program is stored on the storage medium, and the computer program implements the above method when executed by a processor.
[0042] The present invention also relates to an electronic device, characterized in that it comprises a processor and a memory;
[0043] The memory is used to store the verification key;
[0044] The processor is used to execute the above method by calling the verification key.
[0045] The beneficial effects of the present invention are:
[0046] By adopting the Fabric-based transaction concurrency control method and system of the present invention, whether the current transaction is an invalid transaction is determined by checking the key value of the attached verification key and the block to which it belongs in the simulation stage, and whether the current transaction is an invalid transaction is determined by additionally checking whether different transactions in the same block use the same version of the verification key in the sorting stage, thereby achieving invalid transactions and feedback in the simulation and sorting stages before verification, thereby achieving early termination of invalid transactions, effectively saving system resources, and realizing true concurrent transaction control in the three stages of simulation, sorting and verification. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 The figure is a flow chart of the transaction concurrency control method based on Fabric of the present invention.
[0048] Figure 2 The figure is a schematic diagram of the structure of the Fabric-based transaction concurrency control system of the present invention.
[0049] Figure 3 This is a diagram of the transaction concurrency control process of the first embodiment of the present invention.
[0050] Figure 4 This is a diagram of the transaction concurrency control process of the second embodiment of the present invention. DETAILED DESCRIPTION
[0051] In order to more clearly understand the content of the present invention, it will be described in detail with reference to the drawings and embodiments.
[0052] like Figure 1 The figure shows a flow chart of a transaction concurrency control method based on Fabric according to the present invention, which includes:
[0053] S1. Establish a set of verification keys involved in the transaction process, wherein the verification key includes a key value and version number information, wherein the version number information includes the current version number, the transaction ID for executing the update, and the block ID for storing the transaction;
[0054] S2. During the simulation phase, use the verification key to check whether the transaction currently being simulated conflicts with any transaction that has entered the verification phase, and stop simulating the conflicting transaction;
[0055] S3. In the sorting phase, use the verification key to check whether there are conflicts between multiple transactions in the same block currently being sorted, and stop sorting transactions with conflicts;
[0056] S4. Update the key value and version number information of the verification key according to the transaction request.
[0057] Compared with the prior art, the present invention is characterized in that in step S2 and step S3, it is realized to determine the conflicting transactions in the simulation and sorting stage and stop processing, which can save system resources and speed up the transaction feedback speed. When the transaction includes both the request to read and update the verification key, the read request of the transaction is executed first in step S2 and step S3, and for the transaction verified by the read request, the key value and version number information of the verification key are updated according to the update request of the transaction.
[0058] Wherein, step S2 further comprises the following sub-steps:
[0059] S21, identifying the verification key read by the transaction currently being simulated;
[0060] S22, comparing the block ID of the verification key with the latest verified block ID;
[0061] S23. If the block ID of the verification key is greater than the block ID of the latest verified block, it is determined that there is a conflict between the currently executed simulated transaction and any transaction that has entered the verification stage; otherwise, it is determined that there is no conflict between the currently executed simulated transaction and any transaction that has entered the verification stage;
[0062] S24, stop simulating the conflicting transaction and provide feedback to the transaction initiator to resubmit the transaction;
[0063] S25. Submit the simulated transaction to the sorting stage. In particular, after the transaction simulation is successfully executed, a response value and the result of reading the verification key are generated, and the result is endorsed and fed back to the transaction initiator.
[0064] like Figure 3 The figure shows a transaction concurrency control process diagram of the first embodiment of the present invention. The first embodiment provides a situation where conflicting transactions are identified and simulation is stopped during the simulation phase. The specific implementation steps include:
[0065] (1) Obtain the block ID of the last block saved in the ledger of each current accounting node (the latest verified block ID, last-block-ID), which is 4;
[0066] (2) There are two verification keys, balA and balB, which correspond to their own key value and version number information;
[0067] The version number information of the verification key includes the transaction ID (Transaction ID) of the update operation and the ID (Block ID) of the block storing the transaction.
[0068] The current ledger status of the balA and balB verification keys is shown in Table 1:
[0069] Table 1
[0070]
[0071] (3) The client creates a T0 transaction proposal and sends it to each endorsing node;
[0072] The transaction information is as follows:
[0073] T0 transaction: read the value of balA;
[0074] (4) Each endorsing node receives the T0 transaction proposal request:
[0075] ① First, verify whether the signature of the sender is legal. If not, the transaction will be invalid and returned to the client. If it is legal, continue;
[0076] ② Verify whether the transaction proposal format is legal. If it is illegal, the transaction will be invalid and returned to the client;
[0077] ③After verification, call the chain code to simulate the transaction and sign it:
[0078] The value of balA read by transaction T0 is 70:
[0079] Determine whether the block-ID value of the balA key is less than or equal to the value of last-block-ID. The block-ID value of the balA key is 4, which is equal to the value of last-block-ID. This means that the transaction currently being simulated to read the balA value does not have a read-write conflict with all transactions in the verification phase. The transaction is packaged into the next block.
[0080] (5) After simulating the endorsement operation, each endorsement node generates a response value and a transaction result of the read / write set, endorses and signs the result and returns it to the client. The T0 transaction is executed.
[0081] Each transaction treats the read set and write set of each key as a vector of several bits. The number of bits of the vector depends on the number of keys as shown in Table 2:
[0082] Table 2
[0083]
[0084] (6) Next, assume that the block ID of the new block received by each accounting node is 5:
[0085] The new block contains T1 and T2 transactions:
[0086] Transaction T1: Change the value of balA to 50;
[0087] Transaction T2: Change the value of balB to 100;
[0088] First, verify:
[0089] Verify whether the transaction message structure is correct, whether there are duplications, whether there are sufficient endorsements, and whether the read-write set information conflicts;
[0090] The read and write sets of T1 and T2 transactions are shown in Table 3:
[0091] Table 3
[0092]
[0093]
[0094] ① The accounting node verifies transaction T1. After verification, the value of balA is changed to 50. After the modification is successful, the current block ledger status is shown in Table 4:
[0095] Table 4
[0096]
[0097] ② The accounting node verifies transaction T2. After verification, the value of balB is changed to 100. After the modification is successful, the current block ledger status is shown in Table 5:
[0098] Table 5
[0099]
[0100] (7) At the same time as the T1 and T2 transactions, suppose a client creates a T3 transaction proposal and sends it to the endorsing node:
[0101] The transaction information is as follows:
[0102] Transaction T3: read the value of balB;
[0103] (8) The endorsing node verifies the signature and transaction proposal format of the sender. After verification, it simulates the execution of transaction T3, reads the value of balB, and signs:
[0104] At this time, the T1 and T2 transactions have not been verified, that is, the new block with a block ID (block-ID) value of 5 has not been verified, and the current last-block-ID value is still 4. The block-ID value of the balB key is 5, which is greater than the last-block-ID value of 4, indicating that the transaction currently being simulated to read the balB value has a read-write conflict with the transaction in the verification stage, so the transaction cannot be packaged into the next block, and the simulation of the T3 transaction is stopped;
[0105] (9) Notify the responding client to resubmit the T3 transaction application;
[0106] (10) After verifying the T1 and T2 transactions, the write set is submitted to the current state database. The last-block-ID is changed to 5.
[0107] In the first embodiment, the T0 transaction passed the verification of step S2 and completed the simulation; the T1 and T2 transactions only involved updates and did not involve reading the verification key, so they could also pass the simulation; the T3 transaction could not pass the verification of step S2 and the simulation was stopped because the block ID it wanted to read was greater than the latest verified block ID. Compared with the prior art, the method of the present invention can terminate conflicting transactions such as the T3 transaction type in advance, without the need to perform subsequent steps, saving system resources.
[0108] Step S3 further comprises the sub-steps of:
[0109] S31, identifying multiple transactions in the same block that read the same verification key;
[0110] S32. Verify whether the same verification key read by multiple exchanges has the same version number information;
[0111] S33. If the same verification key read by multiple exchanges has different version number information, it is determined that there is a conflict between the multiple transactions in the same block currently being sorted; otherwise, it is determined that there is no conflict between the multiple transactions in the same block currently being sorted;
[0112] S34. For multiple transactions that are in conflict, stop sorting the corresponding transactions with later version number information, and feedback the transaction initiator to resubmit the transaction;
[0113] S35. Submit the sorted transactions to the verification stage, especially sort the unpackaged transactions to generate new blocks, and broadcast the new blocks to other nodes for verification.
[0114] like Figure 4The figure shows a transaction concurrency control process diagram of the second embodiment of the present invention. The second embodiment provides a situation where conflicting transactions are identified and simulation is stopped during the sorting phase. The specific implementation steps include:
[0115] (1) Assume that the block ID (last-block-ID) of the last block saved in the ledger of each accounting node is 7;
[0116] (2) The client creates a T4 transaction proposal and sends it to each endorsing node;
[0117] The transaction information is as follows:
[0118] Transaction T4: Change the value of balA to 150;
[0119] balA verification key, the current ledger status is shown in Table 6:
[0120] Table 6
[0121]
[0122] (3) The endorsing node receives the T4 transaction proposal request:
[0123] ① First, verify whether the signature of the sender is legal. If it is not legal, the transaction will be invalid and returned to the client;
[0124] ② If it is legal, verify whether the transaction proposal format is legal. If it is not legal, indicate that the transaction is invalid and return it to the client;
[0125] ③If it is legal, the chain code is called to simulate the transaction execution;
[0126] ④ After the simulation is successfully executed, the response value and the transaction result of the read / write set are generated, the result is endorsed and signed and returned to the client;
[0127] (4) At the same time, each node receives the latest block with block ID 8, but at this time the block with block ID 8 has not actually passed the verification to become the new last block;
[0128] ① First, verify the T4 transaction contained in the latest block:
[0129] 1) Whether the transaction message structure is correct;
[0130] 2) Whether there is duplication and sufficient endorsement;
[0131] 3) Whether the read-write set information conflicts;
[0132] 4) After the T4 transaction is verified, the value of balA is changed to 150. The T4 transaction completes the simulation phase and will enter the sorting phase. After the modification is successful, the current block ledger status is shown in Table 7:
[0133] Table 7
[0134]
[0135] (5) Further, the client creates a T6 transaction proposal and sends it to the endorsing node:
[0136] The transaction information is as follows:
[0137] Transaction T6: read the value of balA;
[0138] (6) The endorsing node receives the T6 transaction proposal request and first verifies the signature and transaction proposal format of the sender. After verification, it obtains the value of balA as 150 and the block-ID as 8.
[0139] (7) In the sorting phase, since the block-IDs of the same verification key balA read by transactions T4 and T6 are different, the block-ID read by transaction T4 is 7, while the block-ID read by transaction T6 is 8. The block-ID read by transaction T6 is larger than the block-ID read by transaction T4, indicating that transaction T4 involves a change to the key value of balA. Transaction T6 is determined to be an invalid transaction and is no longer sorted, so the transaction is terminated in advance.
[0140] (8) Transaction T4 is submitted to the sorting service, which sorts the unpackaged transactions to generate blocks and then broadcasts them to other nodes;
[0141] (9) After each node verifies the latest block, it adds the new block to the blockchain, submits the write operation set to update the status database, and changes the last-block-ID to 8.
[0142] The present invention also relates to a structure such as Figure 2 The Fabric-based transaction concurrency control system of the structure shown includes:
[0143] Client, used to submit transaction requests and receive feedback results;
[0144] A verification key establishment module, used to establish a set of verification keys involved in the transaction process;
[0145] The transaction simulation module is used to use the verification key to verify whether the transaction currently being simulated conflicts with any transaction that has entered the verification stage, and to simulate the transactions that have passed the verification;
[0146] The transaction sorting module is used to use the verification key to verify whether there are conflicts between multiple transactions in the same block currently being sorted, and to sort the transactions that have passed the verification;
[0147] The transaction verification module is used to verify the new blocks generated by the transaction.
[0148] The system can be used to execute the transaction concurrency control method mentioned above.
[0149] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A transaction concurrency control method based on Fabric, characterized in that: include: S1. Establish a set of verification keys involved in the transaction process, wherein the verification key includes a key value and version number information, wherein the version number information includes the current version number, the transaction ID for executing the update, and the block ID for storing the transaction; S2. During the simulation phase, use the verification key to check whether the transaction currently being simulated conflicts with any transaction that has entered the verification phase, and stop simulating the conflicting transaction; S3. In the sorting phase, use the verification key to check whether there are conflicts between multiple transactions in the same block currently being sorted, and stop sorting transactions with conflicts; S4. Update the key value and version number information of the verification key according to the transaction request; Wherein, step S2 further comprises the following sub-steps: S21, identifying the verification key read by the transaction currently being simulated; S22, comparing the block ID of the verification key with the latest verified block ID; S23. If the block ID of the verification key is greater than the block ID of the latest verified block, it is determined that there is a conflict between the currently executed simulated transaction and any transaction that has entered the verification stage; otherwise, it is determined that there is no conflict between the currently executed simulated transaction and any transaction that has entered the verification stage; S24, stop simulating the conflicting transaction and provide feedback to the transaction initiator to resubmit the transaction; S25, submitting the simulated transactions to the sorting stage; Step S3 further comprises the steps of: S31, identifying multiple transactions in the same block that read the same verification key; S32. Verify whether the same verification key read by multiple exchanges has the same version number information; S33. If the same verification key read by multiple exchanges has different version number information, it is determined that there is a conflict between the multiple transactions in the same block currently being sorted; otherwise, it is determined that there is no conflict between the multiple transactions in the same block currently being sorted; S34. For multiple transactions that are in conflict, stop sorting the corresponding transactions with later version number information, and feedback the transaction initiator to resubmit the transaction; S35. Submit the sorted transactions to the verification stage; Step S4 further comprises the steps of: S41. Verify whether the transaction signature is legal. If the verification is illegal, feedback is given to the transaction initiator to resubmit the transaction; S42. Further verify whether the transaction content is legal for the transaction that has passed the signature verification. If the verification is illegal, the transaction initiator is fed back to resubmit the transaction; S43. For transactions that pass content verification, update the key value and version number information of the verification key according to the transaction request.
2. The method according to claim 1, characterized in that The version number information of the update verification key includes modifying the transaction ID for executing the update and the block ID for storing the transaction, and generating a new current version number.
3. The method according to claim 1, characterized in that The method further comprises: When a transaction includes both requests to read and update the verification key, steps S2 and S3 are executed first to verify the read request of the transaction, and for the transaction verified by the read request, the key value and version number information of the verification key are updated according to the update request of the transaction.
4. The method according to claim 1, characterized in that The sub-step S25 comprises: After the transaction simulation is successfully executed, a response value and the result of reading the verification key are generated, and the result is endorsed and fed back to the transaction initiator.
5. The method according to claim 1, characterized in that The sub-step S35 comprises: Sort the unpackaged transactions to generate new blocks, and broadcast the new blocks to other nodes for verification.
6. A Fabric-based transaction concurrency control system, characterized in that: For executing the method according to claim 1, comprising: Client, used to submit transaction requests and receive feedback results; A verification key establishment module, used to establish a set of verification keys involved in the transaction process; The transaction simulation module is used to use the verification key to verify whether the transaction currently being simulated conflicts with any transaction that has entered the verification stage, and to simulate the transactions that have passed the verification; The transaction sorting module is used to use the verification key to verify whether there are conflicts between multiple transactions in the same block currently being sorted, and to sort the transactions that have passed the verification; The transaction verification module is used to verify the new blocks generated by the transaction.
7. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
8. An electronic device, characterized in that: including a processor and a memory; The memory is used to store the verification key; The processor is used to execute the method according to any one of claims 1 to 5 by calling a verification key.
