CN112488832B - A transaction execution method, device and storage medium - Google Patents
A transaction execution method, device and storage medium Download PDFInfo
- Publication number
- CN112488832B CN112488832B CN202011320377.7A CN202011320377A CN112488832B CN 112488832 B CN112488832 B CN 112488832B CN 202011320377 A CN202011320377 A CN 202011320377A CN 112488832 B CN112488832 B CN 112488832B
- Authority
- CN
- China
- Prior art keywords
- transaction
- node
- account
- transaction content
- content
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q40/00—Finance; Insurance; Tax strategies; Processing of corporate or income taxes
- G06Q40/04—Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q20/00—Payment architectures, schemes or protocols
- G06Q20/38—Payment protocols; Details thereof
- G06Q20/382—Payment protocols; Details thereof insuring higher security of transaction
- G06Q20/3829—Payment protocols; Details thereof insuring higher security of transaction involving key management
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q20/00—Payment architectures, schemes or protocols
- G06Q20/38—Payment protocols; Details thereof
- G06Q20/389—Keeping log of transactions for guaranteeing non-repudiation of a transaction
Landscapes
- Business, Economics & Management (AREA)
- Accounting & Taxation (AREA)
- Engineering & Computer Science (AREA)
- Finance (AREA)
- General Physics & Mathematics (AREA)
- General Business, Economics & Management (AREA)
- Physics & Mathematics (AREA)
- Strategic Management (AREA)
- Theoretical Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Development Economics (AREA)
- Economics (AREA)
- Marketing (AREA)
- Technology Law (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The embodiment of the invention provides a transaction execution method which is applied to a first node and comprises the steps of receiving a transaction request sent by a second node, wherein the transaction request carries a signature, a transaction account and transaction contents, verifying the transaction contents by using a temporary account book under the condition that the signature verification is legal and the transaction account is stored in a preset list, simulating and executing the transaction contents under the condition that the signature verification is legal, and recording the transaction results in the temporary account book. The task method provided by the embodiment of the invention can solve the problem of reduced query efficiency caused by frequent query of the local account book in the related technology.
Description
Technical Field
The present invention relates to the field of information technologies, and in particular, to a transaction execution method, a transaction execution device, and a storage medium.
Background
In most blockchain systems, during the forwarding process of a transaction, other nodes perform preliminary verification on the validity of the transaction, wherein the preliminary verification includes verification on the validity of a transaction signature and the validity of transaction content, the verification on the validity of the transaction content mainly depends on data of a local account book, and the transaction after preliminary verification is broadcasted on the whole network and then subjected to consensus packaging to generate a block.
Under the high-frequency transaction environment, frequent inquiry of the local ledger can reduce the inquiry efficiency, further increase the inquiry result delay, and be unfavorable for the quick broadcasting of the transaction.
Disclosure of Invention
The invention provides a transaction execution method, a transaction execution device and a storage medium, which are used for solving the problem that the query efficiency is reduced due to frequent query of a local account book in the related technology.
The embodiment of the invention provides a transaction execution method which is applied to a first node and comprises the steps of receiving a transaction request sent by a second node, wherein the transaction request carries a signature, a transaction account and transaction contents, verifying the transaction contents by using a temporary account book under the condition that signature verification is legal and the transaction account is stored in a preset list, simulating and executing the transaction contents under the condition that verification is legal, and recording a transaction result in the temporary account book.
Optionally, after the transaction content is simulated and executed, the method further comprises the steps of sending the transaction content to a consensus node, receiving a block generated by the consensus node according to the transaction content, wherein the block carries the signature and the transaction content, executing the transaction content in the block, and recording the generated transaction result in a local account book.
Optionally, the executing the transaction content in the block includes verifying whether the block is legal, analyzing the block to generate the signature and the transaction content if the block is legal, verifying whether the signature and the transaction content are legal, and executing the transaction content if the block is legal.
Optionally, after the transaction content is sent to the consensus node, the method further comprises the steps of judging whether the transaction content in the temporary account book is simulated and executed or not under the condition that a block generated by the consensus node according to the transaction content is not received within preset time, and rolling back the transaction result recorded in the temporary account book under the condition that the judgment result is yes.
Optionally, after the transaction content is sent to the consensus node, the method further comprises the steps of judging whether the transaction content in the temporary account book is simulated and executed or not under the condition that the transaction content is not validated and legal, and rolling back the transaction result recorded in the temporary account book under the condition that the judgment result is yes.
Optionally, after receiving the transaction request sent by the second node, the method further comprises verifying the transaction content by using the local ledger under the condition that the signature verification is legal and the transaction account is not stored in a preset list.
Optionally, before the temporary account book is used for verifying the transaction content, the method further comprises the steps of obtaining information of transaction accounts with transaction frequency exceeding a preset threshold value, and recording the transaction accounts with the transaction frequency exceeding the preset threshold value into the list.
The embodiment of the invention also provides a transaction execution method which is applied to the third node and comprises the steps of receiving a block sent by the consensus node, wherein the block carries a signature, a transaction account and transaction contents, judging whether the transaction contents are simulated and executed or not under the condition that the signature and the transaction contents are verified to be legal and the transaction account is stored in a preset list, and under the condition that the judgment result is negative, simulating and executing the transaction contents and recording the transaction results in a temporary account book and a local account book.
The embodiment of the invention also provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program realizes any one of the methods of the embodiment of the invention when being executed by a processor.
The embodiment of the invention also provides an electronic device which comprises a memory and a processor, wherein the processor realizes any one of the methods of the embodiment of the invention by executing the program in the memory.
The task method provided by the embodiment of the invention can solve the problem of reduced query efficiency caused by frequent query of the local account book in the related technology.
Drawings
FIG. 1 is a flow chart of a transaction execution method according to an embodiment of the present invention;
FIG. 2 is a flow chart of another transaction execution method according to an embodiment of the present invention;
FIG. 3 is a flow chart of yet another method of transaction execution according to an embodiment of the present invention;
FIG. 4 is a flow chart of a method for a node to initially verify the legitimacy of a transaction in accordance with an embodiment of the present invention;
FIG. 5 is a flow chart of a method for a node to transact a block in accordance with an embodiment of the present invention;
FIG. 6 is a flow chart of a rollback method for timeout unprocessed transactions according to an embodiment of the present invention;
FIG. 7 is a block diagram of a transaction execution method according to an embodiment of the present invention;
FIG. 8 is a block diagram of a transaction execution device according to an embodiment of the present invention;
FIG. 9 is a block diagram of another transaction execution device according to an embodiment of the present invention;
fig. 10 is a block diagram of still another transaction execution device according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present application more apparent, embodiments of the present application will be described in detail hereinafter with reference to the accompanying drawings. It should be noted that, without conflict, the embodiments of the present application and features of the embodiments may be arbitrarily combined with each other.
In addition, in the embodiments of the present invention, the words "optional" or "exemplary" and the like are used to mean serving as an example, instance, or illustration. Any embodiment or design described herein as "optional" or "exemplary" is not necessarily to be construed as preferred or advantageous over other embodiments or designs. Rather, the use of the words "optional" or "exemplary" and the like is intended to present related concepts in a concrete fashion.
An embodiment of the present invention provides a transaction execution method, and fig. 1 is a flowchart of a transaction execution method according to an embodiment of the present invention, where the method is applied to a first node, and the method includes the following steps:
s102, receiving a transaction request sent by a second node, wherein the transaction request carries a signature, a transaction account and transaction contents;
s104, under the condition that the signature verification is legal and the transaction account is stored in a preset list, verifying the transaction content by using a temporary account book;
s106, under the condition of verifying legal, simulating and executing the transaction content, and recording the transaction result in the temporary account book.
According to the method provided by the embodiment of the invention, the temporary account book is stored in the first node in the network, the first node performs preliminary validity check on the transaction request sent by the second node through the temporary account book, and after the validation is legal, a simulation transaction result is generated in a simulation execution mode. Therefore, the work of checking transaction contents of the local account book is shared, and the node processing efficiency is improved.
Optionally, after the transaction content is simulated, the method further comprises the steps of sending the transaction content to a consensus node, receiving a block generated by the consensus node according to the transaction content, wherein the block carries the signature and the transaction content, executing the transaction content in the block, and recording the generated transaction result in a local account book.
After the transaction is judged to be legal preliminarily, the first node broadcasts the transaction information and then packages the transaction information through the consensus node to generate a new block, the first node receives the block generated by the consensus node and verifies the block, the signature in the block and the transaction content in the block respectively, and under the condition of legal verification, the first node formally executes the transaction content, records the transaction result in a local account book and feeds back the transaction result to the second node. It can be seen that the temporary account book is only used for carrying out preliminary verification of the transaction, and finally the transaction result actually executed and generated is still written into the local account book, so that the validity of the local account book is ensured.
Optionally, the executing the transaction content in the block includes verifying whether the block is legal, parsing the block to generate the signature and the transaction content if the block is legal, verifying whether the signature and the transaction content are legal, and executing the transaction content if the block is legal.
Optionally, after the transaction content is sent to the consensus node, the method further comprises the steps of judging whether the transaction content in the temporary account book is simulated and executed or not under the condition that a block generated by the consensus node according to the transaction content is not received within preset time, and rolling back the transaction result recorded in the temporary account book under the condition that the judgment result is yes.
In the process that the first node broadcasts the transaction content or in the process that the consensus node feeds back the block to the first node, network delay may exist, if the block is not received within a preset time, the transaction is overtime, and at this time, the cache information of the first node for simulating the transaction execution and the transaction result information stored in the temporary account book need to be rolled back and cleaned.
Optionally, after the transaction content is sent to the consensus node, the method further comprises the steps of judging whether the transaction content in the temporary account book is simulated and executed or not under the condition that the transaction content is not validated and legal, and rolling back the transaction result recorded in the temporary account book under the condition that the judgment result is yes.
Optionally, after receiving the transaction request sent by the second node, the method further comprises verifying the transaction content by using the local ledger under the condition that the signature verification is legal and the transaction account is not stored in a preset list.
The first node manages a local account book and a temporary account book simultaneously, wherein the local account book is stored in a file form for local management, and the temporary account book is stored in a memory of the first node. Under the condition that the transaction account received by the first node is stored in a list, checking is carried out through a temporary account book; and checking through a local account book in the case that the transaction account received by the first node is not stored in the list.
Optionally, before the temporary account book is used for verifying the transaction content, the method further comprises the steps of obtaining information of transaction accounts with transaction frequency exceeding a preset threshold value, and recording the transaction accounts with the transaction frequency exceeding the preset threshold value into the list.
The account information of the high-frequency transaction is recorded in the list, and the temporary account book is adopted for verifying the transaction validity of all accounts in the list, so that the transaction efficiency can be improved.
The embodiment of the invention also provides a transaction execution method, and fig. 2 is a flowchart of another transaction execution method according to an embodiment of the invention, where the method is applied to a third node, and the method includes the following steps:
s202, receiving a block sent by a consensus node, wherein the block carries a signature, a transaction account and transaction contents;
s204, judging whether the transaction content is simulated to be executed or not under the condition that the signature and the transaction content are verified to be legal and the transaction account is stored in a preset list;
s206, if the judgment result is negative, simulating and executing the transaction content, and recording the transaction result in the temporary account book and the local account book.
The consensus node generates a block after packaging the transaction and transmits the block to the all-network node, wherein the block comprises nodes which are about to actually transact and nodes which do not actually transact. For the nodes which do not actually transact, the validity of the block and the signature and the transaction content carried by the block are verified, the transaction content is simulated and executed, and the transaction results are recorded in the temporary account book and the local account book, so that the network node can record the transaction.
An embodiment of the present invention further provides a transaction execution method, and fig. 3 is a flowchart of another transaction execution method according to an embodiment of the present invention. As shown in fig. 3, the method comprises the steps of:
step 3.1, initializing transaction by the client and sending a transaction request to the node;
step 3.2, after receiving the transaction request, the node starts preliminary verification;
Step 3.3, after the node initially verifies that the transaction passes, the transaction is simulated and executed, and the transaction is sent to the consensus node;
step 3.4, the consensus node orders the received transactions, packages the transactions and generates a new block;
Step 3.5, the consensus node sends a new block to the whole network node;
step 3.6, the nodes process according to the commonly recognized blocks and update the data in the local account book at the same time;
And step 3.7, the node returns the final execution result to the client.
Fig. 4 is a flowchart of a method for initially verifying the validity of a transaction by a node according to an embodiment of the present invention, as shown in fig. 4, the method including the steps of:
Step 4.1, broadcasting and sending a transaction request to the node by the client or other nodes, wherein the request comprises a corresponding digital signature;
Step 4.2, the node judges whether the related account data is in a list maintained by the node, if so, the node accesses the temporary account book to acquire data and enters step 4.3, otherwise, the node accesses the local account book and enters step 4.4;
The nodes in the network can maintain a local account book and a temporary account book at the same time, the local account book is stored in a file form for local management, and the temporary account book is stored in a memory. A list of transaction accounts is also maintained in the node, which serves the temporary ledger. The management mode of the list can comprise two modes:
scheme one, node adaptive tuning
1) Setting temporary account book parameters according to a memory, wherein the temporary account book parameters comprise the maximum number of related accounts, the maximum number of cache transactions and the like;
2) And determining the priority of the account according to the account transaction data, and incorporating the account into the temporary account book according to the priority. Where the priority may be determined based on the magnitude of the tps (transaction per second) value of the transaction for a period of time of the account.
In a first approach, the management of the lists is personalized, i.e. the lists are different for each node in the network.
Scheme II and whole network unified arrangement
1) An administrator configures a unified account list at all network nodes according to the block data to ensure that account data of different temporary account books are consistent;
2) And the node generates a unified temporary account list of the nodes of the whole network through an automatic program according to the block data.
In the second scheme, the above two methods can make the lists of all the nodes of the whole network temporary account uniform when the block heights are uniform.
Step 4.3, the node verifies whether the transaction content is legal or not according to the temporary account book, if the transaction is legal, the transaction content is simulated and executed, otherwise, the transaction is returned to be invalid;
And 4.4, the node verifies whether the transaction content is legal or not according to the local account book, if the transaction is legal, the node determines that the transaction is legal, and if not, the node returns that the transaction is invalid.
Fig. 5 is a flowchart of a method for processing transactions on blocks by a node according to an embodiment of the present invention, as shown in fig. 5, the method includes the following steps:
Step 5.1, the node receives the block which is generated by the packaging of the consensus mechanism;
step 5.2, the node verifies whether the block is legal or not, if so, the transaction set is analyzed, and if not, the transaction is returned to be invalid;
Step 5.3, the node verifies whether the signature is legal or not, if yes, the node continues to verify, and if not, the node returns that the transaction is invalid;
Step 5.4, the node verifies whether the transaction content is legal or not:
In addition, judging whether the transaction of the temporary account book is executed or not, if so, cleaning a cache, and if not, supplementing the simulated execution transaction;
If the transaction is not legal, refusing the execution of the transaction, verifying whether the transaction is simulated, if so, rolling back the transaction content to update the temporary account book information and clear the corresponding cache transaction, and if not, directly ending the flow.
FIG. 6 is a flow chart of a rollback method for timeout unprocessed transactions according to an embodiment of the present invention, as shown in FIG. 6, comprising the steps of:
Step 6.1, the client sends a transaction request to the node;
step 6.2, the node simulates and executes the transaction;
and 6.3, periodically verifying whether the cached transaction is really executed or not after overtime by the node, if so, updating temporary account information and clearing cache information of the corresponding transaction by rolling back transaction contents, and otherwise, continuing caching.
This may occur in situations where the system has not packed a transaction into blocks due to node failure discarding the transaction or buffering an out-of-date transaction, resulting in a buffered transaction timeout not actually performed, thus having to rollback the transaction contents, update temporary ledger information, and clear the buffered information for the corresponding transaction.
The following describes the scheme of the embodiment of the present invention in connection with a specific scenario.
Example 1, single transfer transaction example
The full network node maintains a list of accounts as follows:
Sequence number | Account account |
A | 6XXX1 |
C | 6XXX3 |
F | 6XXX6 |
G | ... |
Accounts that are not on the list are B account 6XXX2, D account 6XXX4, E account 6XXX5.
The primary balance of the account A is 1000.00 yuan, the primary balance of the account B is 0.00 yuan, and the balance of the temporary account book is consistent with the balance of the local account book.
1) The client initiates a single transfer transaction 1 to the node 2, the account A is transferred to the account B, and the transfer amount is 100.00 yuan;
2) The node 2 receives the request information { signature, public key, A, B, 100.00}, which is sent from the client, firstly verifies whether the signature is legal, if not, returns that the transaction is invalid, if so, continues, and each transaction verifies whether the signature is legal, and the subsequent embodiments are not repeated
3) Judging whether the account A is in a list maintained by the whole network node;
4) The node 2 uses the temporary account book to simulate and execute the transaction, and the balance of the account A is 1000.00-100.00=900.00 (yuan);
The account information after the node 2 simulates and executes the transaction is as follows:
Account account | Local ledger state | Temporary ledger status |
A | 1000.00 | 900.00 |
B | 0.00 | Null |
C | 0.00 | 0.00 |
...... |
Note that account B is not in the temporary ledger list, so the temporary ledger does not store the state of account B, denoted nul l.
5) Broadcasting the transaction through the whole network, and generating a block through consensus packaging;
6) And each node receives the new block of the consensus package, analyzes the transfer transaction 1 and verifies whether the transaction content is legal.
Fig. 7 is a block diagram of a transaction execution method according to an embodiment of the present invention, and after executing a transaction on a block, as shown in fig. 7, information of corresponding nodes is changed as follows:
node 2, temporary account book has simulated the transaction, so the buffer memory is cleaned, no rollback is caused, the local account book is used for accounting, and the account balance A is 900.00 (yuan);
Node 1 and node 3, performing transfer transaction 1 using temporary ledger simulation, local ledger accounting;
A account balance 900.00 and B account balance 100.00
After the node 2 performs transaction execution on the block, account information of the node 1, the node 2 and the node 3 is as follows:
Account account | Local ledger state | Temporary ledger status |
A | 900.00 | 900.00 |
B | 100.00 | Null |
C | 0.00 | 0.00 |
...... |
Example 2 multiple transfer transaction example
The full network node maintains a list of accounts as follows:
Sequence number | Account account |
A | 6XXX1 |
C | 6XXX3 |
F | 6XXX6 |
G | ... |
Accounts that are not on the list are B account 6XXX2, D account 6XXX4, E account 6XXX5.
The primary balance of the account A is 900.00 yuan, the primary balance of the account B is 100.00 yuan, and the balance of the temporary account book is consistent with the balance of the local account book.
The client side sequentially initiates a transfer transaction 2, a transfer transaction 3 and a transfer transaction 4, and the transaction information is as follows:
transferring the account A to the account B in the transfer transaction 2, wherein the transfer amount is 200.00 yuan;
Transferring the account A to the account C in the transfer transaction 3, wherein the transfer amount is 500.00 yuan;
transferring the account C to the account B in the transfer transaction 4, wherein the transfer amount is 200.00 yuan;
1) The client sends a transfer transaction 2, a transfer transaction 3 and a transfer transaction 4 to the node 2;
a. Account A in the account list, node 2 uses temporary account book to verify the validity of the content of transaction 2, the balance 900.00 of account A is greater than the transfer amount 200.00, the content of transaction is legal, node 2 uses temporary account book to simulate and execute transaction, the balance 900.00-200.00=700.00 (yuan);
b. Account A and account C are in the account list, node 2 uses temporary account book to verify the validity of the transaction 3 content, the balance 700.00 of account A is greater than the transfer amount 500.00, the transaction content is legal, node 2 uses temporary account book to simulate and execute the transaction, the balance 700.00-500.00=200.00 (yuan), the balance 0.00+500.00=500.00 (yuan);
c. Account C in account list, node 2 uses temporary account book to verify the legitimacy of the content of transaction 4, C account balance is 500.00 greater than transfer amount 200.00, the content of transaction is legal, node 2 uses temporary account book to simulate and execute transaction, C account balance is 500.00-200.00=300.00 (yuan);
The account information after the simulation execution of the node 2 is as follows:
Account account | Local ledger state | Temporary ledger status |
A | 900.00 | 200.00 |
B | 100.00 | Null |
C | 0.00 | 300.00 |
...... |
2) A whole-network broadcast block of the transfer transaction 2, the transfer transaction 3 and the transfer transaction 4;
3) Each node receives the new block of the consensus package, and the consensus node temporarily does not receive the transaction 3 because of the reasons such as network, so each node analyzes the transfer transaction 2 and the transfer transaction 4 and verifies the legality of the transaction content:
Transfer transaction 2:
a. verifying that the transaction content is legal, the temporary account book of the node 2 has simulated the transfer transaction 2, so that the transfer transaction 2 is cleaned up and cached and is not rolled back
900.00-200.00=700.00 (Yuan);
at this time, account information after the node 2 performs transaction execution on the block is as follows:
Account account | Local ledger state | Temporary ledger status |
A | 700.00 | 200.00 |
B | 300.00 | Null |
C | 0.00 | 300.00 |
...... |
B. before the node 1 and the node 3 receive the block, the transfer transaction 2, the transfer transaction 3 and the transfer transaction 4 are not received, the temporary account book needs to simulate and execute the transfer transaction 2, and the local account book also changes according to the content in the transaction 2;
At this time, the account information of the node 1 and the node 3 is as follows:
Account account | Local ledger state | Temporary ledger status |
A | 700.00 | 700.00 |
B | 300.00 | Null |
C | 0.00 | 0.00 |
...... |
Transfer transaction 4:
c. verifying transaction content:
The balance of the C local account of the node 2 is 0.00 less than the transfer amount of 200.00, the transaction content is illegal, and the transaction is refused. The temporary account roll-back of the node 2 simulates the transfer transaction 4 executed, the balance of the C account is 300.00+200.00=500.00 (element), and the cache information of the cache transfer transaction 4 is cleared.
At this time, the account information after the node 2 rolls back is as follows:
node 1 and node 3 do not need to rollback transaction 4 because they have not simulated transactions, and thus all account states of node 1 and node 3 remain unchanged.
Example 3, time out unprocessed transaction rollback example
The full network node maintains a list of accounts as follows:
Sequence number | Account account |
A | 6XXX1 |
C | 6XXX3 |
F | 6XXX6 |
G | ... |
Accounts that are not on the list are B account 6XXX2, D account 6XXX4, E account 6XXX5.
The account information of node 2 is as follows:
Account account | Local ledger state | Temporary ledger status |
A | 700.00 | 200.00 |
B | 300.00 | Null |
C | 0.00 | 500.00 |
...... |
The account information for node 1 and node 3 is as follows:
Account account | Local ledger state | Temporary ledger status |
A | 700.00 | 700.00 |
B | 300.00 | Null |
C | 0.00 | 0.00 |
...... |
Suppose transaction 3 eventually times out, i.e., is not recorded into a block within a time set by the system.
At this point, since only node 2 has simulated execution, node 2 needs to rollback the transaction and then clear the transaction. Re-transferring the content of the transfer transaction 3 from the account A to the account C, wherein the transfer amount is 500.00 yuan;
because A and C are on the list, after the rollback transaction, A account is +500 Yuan, C account is-500 Yuan
The account information of node 2 is as follows:
Account account | Local ledger state | Temporary ledger status |
A | 700.00 | 200.00+500.00=700.00 |
B | 300.00 | Null |
C | 0.00 | 500.00-500.00=0.00 |
...... |
It can be seen that at this time, the states of node 1, node 2, and node 3 are identical.
Finally, the transaction in the cache is cleaned up.
The embodiment of the invention also provides a transaction execution device, which is applied to a first node, fig. 8 is a block diagram of the transaction execution device according to the embodiment of the invention, and the device comprises a first receiving module 82, a first verifying module 84 and a first executing module 86, wherein,
The first receiving module 82 is configured to receive a transaction request sent by the second node, where the transaction request carries a signature, a transaction account and transaction content;
the first verification module 84 is configured to verify the transaction content using a temporary ledger if the signature verification is legal and the transaction account is stored in a preset list;
The first execution module 86 is configured to simulate and execute the transaction content and record the transaction result in the temporary account book if the validation is legal.
Optionally, the device further comprises a sending module, a second receiving module and a second executing module, wherein the sending module is used for sending the transaction content to a consensus node, the second receiving module is used for receiving a block generated by the consensus node according to the transaction content, the block carries the signature and the transaction content, and the second executing module is used for executing the transaction content in the block and recording the generated transaction result in a local account book.
Optionally, the second execution module is specifically configured to verify whether the block is legal, parse the block to generate the signature and the transaction content if the block is legal, verify whether the signature and the transaction content are legal, and execute the transaction content if the block is legal.
Optionally, the device further comprises a first judging module, which is used for judging whether the transaction content in the temporary account book is simulated and executed or not under the condition that the block generated by the consensus node according to the transaction content is not received within a preset time after the transaction content is sent to the consensus node, and rolling back the transaction result recorded in the temporary account book under the condition that the judgment result is yes.
Optionally, the device further comprises a second judging module, which is used for judging whether the transaction content in the temporary account book is simulated and executed or not under the condition that the verification of the transaction content is illegal after the transaction content is sent to the consensus node, and carrying out rollback on the transaction result recorded in the temporary account book under the condition that the judgment result is yes.
Optionally, the device further includes a second verification module, configured to verify the transaction content using the local ledger after receiving the transaction request sent by the second node, where the signature verification is legal and the transaction account is not stored in a preset list.
Optionally, the device further comprises a recording module, wherein the recording module is used for acquiring information of the transaction accounts with the transaction frequency exceeding a preset threshold before the temporary account book is used for verifying the transaction content, and recording the transaction accounts with the transaction frequency exceeding the preset threshold into the list.
An embodiment of the present invention further provides a transaction execution device, applied to a third node, fig. 9 is a block diagram of another transaction execution device according to an embodiment of the present invention, where the device includes a receiving module 92, a judging module 94 and an executing module 96, where,
The receiving module 92 is configured to receive a block sent by the consensus node, where the block carries a signature, a transaction account, and transaction content;
the judging module 94 is configured to judge whether the transaction content is simulated and executed if the signature and the transaction content are verified to be legal and the transaction account is stored in a preset list;
The execution module 96 is configured to simulate and execute the transaction content and record the transaction results in the temporary ledger and the local ledger if the determination result is negative.
An embodiment of the present invention further provides a transaction execution device, fig. 10 is a block diagram of yet another transaction execution device according to an embodiment of the present invention, the device including a listing module 102, a temporary ledger module 104, a local ledger module 106, and a communication module 108, wherein,
The list module 102 is configured to maintain list data and provide services for the temporary account book;
the temporary account book module 104 is configured to read the local account book file to the memory to form a temporary account book file, and perform preliminary verification of the transaction;
The local ledger module 106 is configured to store a local ledger file in a file form to be managed locally;
The communication module 108 is configured to interact between nodes.
The embodiment of the invention also provides an electronic device which comprises the processors and a memory, wherein the number of the processors in the electronic device can be one or more, and the memory is used as a computer readable storage medium and can be used for storing computer executable programs. The processor executes the software programs and instructions stored in the memory to perform the various functional applications of the electronic device and data processing, i.e., to implement the methods of any of the embodiments described above.
Embodiments of the present application also provide a storage medium containing computer-executable instructions that, when executed by a computer processor, implement the method of any of the embodiments described above.
Optionally, the processor implements a transaction execution method by executing instructions, the method being applied to the first node and comprising:
s1, receiving a transaction request sent by a second node, wherein the transaction request carries a signature, a transaction account and transaction contents;
s2, under the condition that the signature verification is legal and the transaction account is stored in a preset list, verifying the transaction content by using a temporary account book;
And S3, under the condition of verifying legal, simulating and executing the transaction content, and recording a transaction result in the temporary account book.
The foregoing is merely exemplary embodiments of the present application and is not intended to limit the scope of the present application.
In general, the various embodiments of the application may be implemented in hardware or special purpose circuits, software, logic or any combination thereof. For example, some aspects may be implemented in hardware, while other aspects may be implemented in firmware or software which may be executed by a controller, microprocessor or other computing device, although the application is not limited thereto.
Embodiments of the application may be implemented by a data processor of a mobile device executing computer program instructions, e.g. in a processor entity, either in hardware, or in a combination of software and hardware. The computer program instructions may be assembly instructions, instruction Set Architecture (ISA) instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source or object code written in any combination of one or more programming languages.
The block diagrams of any of the logic flows in the figures of this application may represent program steps, or may represent interconnected logic circuits, modules, and functions, or may represent a combination of program steps and logic circuits, modules, and functions. The computer program may be stored on a memory. The memory may be of any type suitable to the local technical environment and may be implemented using any suitable data storage technology, such as, but not limited to, read Only Memory (ROM), random Access Memory (RAM), optical storage devices and systems (digital versatile disk DVD or CD optical disk), etc. The computer readable medium may include a non-transitory storage medium. The data processor may be of any type suitable to the local technical environment, such AS, but not limited to, general purpose computers, special purpose computers, microprocessors, digital Signal Processors (DSPs), application specific integrated circuits (AS ICs), programmable logic devices (FGPAs), and processors based on a multi-core processor architecture.
The foregoing detailed description of exemplary embodiments of the application has been provided by way of exemplary and non-limiting examples. Various modifications and adaptations to the above embodiments may become apparent to those skilled in the art without departing from the scope of the application, which is defined in the accompanying drawings and claims. Accordingly, the proper scope of the application is to be determined according to the claims.
Claims (9)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011320377.7A CN112488832B (en) | 2020-11-23 | 2020-11-23 | A transaction execution method, device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011320377.7A CN112488832B (en) | 2020-11-23 | 2020-11-23 | A transaction execution method, device and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112488832A CN112488832A (en) | 2021-03-12 |
CN112488832B true CN112488832B (en) | 2025-03-07 |
Family
ID=74933491
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011320377.7A Active CN112488832B (en) | 2020-11-23 | 2020-11-23 | A transaction execution method, device and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112488832B (en) |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109345251A (en) * | 2018-08-24 | 2019-02-15 | 深圳壹账通智能科技有限公司 | Negotiable block chain method of commerce, device, equipment and storage medium |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2018120121A1 (en) * | 2016-12-30 | 2018-07-05 | 深圳前海达闼云端智能科技有限公司 | Block chain permission control method, device, and node apparatus |
CN109840771A (en) * | 2019-04-01 | 2019-06-04 | 西安电子科技大学 | A kind of block chain intimacy protection system and its method based on homomorphic cryptography |
CN111861477A (en) * | 2020-08-06 | 2020-10-30 | 深圳壹账通智能科技有限公司 | Block chain-based post-transaction data processing method and device and computer equipment |
-
2020
- 2020-11-23 CN CN202011320377.7A patent/CN112488832B/en active Active
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109345251A (en) * | 2018-08-24 | 2019-02-15 | 深圳壹账通智能科技有限公司 | Negotiable block chain method of commerce, device, equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN112488832A (en) | 2021-03-12 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108648078B (en) | Transaction preprocessing method and device and electronic equipment | |
EP3811316B1 (en) | Blockchain system and method | |
US20200134613A1 (en) | Method and Apparatus for Running Smart Contract | |
CN110751475A (en) | Cross-chain method, system, equipment and storage medium for blockchain transaction | |
WO2019223469A1 (en) | Block chain network management method, device, medium and electronic device | |
WO2019042101A1 (en) | Cross-chain trading method and apparatus | |
CN108805701B (en) | Multi-blockchain cross-chain transaction processing system and method, blockchain system and storage medium | |
CN110033373A (en) | Device, method and the storage medium endorsed in block chain | |
CN111275438B (en) | Consensus method, device, equipment and storage medium of block chain network | |
WO2021098139A1 (en) | Method and device for storing state data of cross-chain transaction, and storage medium | |
CN109710695B (en) | Transaction request validity identification and initiation method, device, equipment and medium | |
CN113568981B (en) | Transaction data processing method, device, equipment and medium | |
CN113760976B (en) | Service processing method, device, equipment and storage medium | |
Pedone et al. | Byzantine fault-tolerant deferred update replication | |
CN109040263B (en) | Distributed system-based business processing method and device | |
CN112767151A (en) | Transaction processing method and device applied to verification node in block chain | |
CN111489156A (en) | Blockchain-based transaction method, electronic device and readable storage medium | |
WO2016101759A1 (en) | Data routing method, data management device and distributed storage system | |
US20070118597A1 (en) | Processing proposed changes to data | |
CN107277108B (en) | A message processing method, device and system at a node of a blockchain | |
CN116977067A (en) | Block chain-based data processing method, device, equipment and readable storage medium | |
CN110162274B (en) | Data processing method, device and equipment based on block chain | |
CN112488832B (en) | A transaction execution method, device and storage medium | |
CN111181731B (en) | Execution optimization method, system and storage medium of smart contract in alliance chain | |
CN119402502B (en) | Blockchain transaction cancellation method and device and blockchain transaction system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |