CN112488832A - Transaction execution method, device and storage medium - Google Patents

Transaction execution method, device and storage medium Download PDF

Info

Publication number
CN112488832A
CN112488832A CN202011320377.7A CN202011320377A CN112488832A CN 112488832 A CN112488832 A CN 112488832A CN 202011320377 A CN202011320377 A CN 202011320377A CN 112488832 A CN112488832 A CN 112488832A
Authority
CN
China
Prior art keywords
transaction
account
node
content
transaction 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.)
Pending
Application number
CN202011320377.7A
Other languages
Chinese (zh)
Inventor
陈志明
姜鹏
曲傲
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Citic Bank Corp Ltd
Original Assignee
China Citic Bank Corp Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by China Citic Bank Corp Ltd filed Critical China Citic Bank Corp Ltd
Priority to CN202011320377.7A priority Critical patent/CN112488832A/en
Publication of CN112488832A publication Critical patent/CN112488832A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION 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/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION 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/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3829Payment protocols; Details thereof insuring higher security of transaction involving key management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION 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/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/389Keeping log of transactions for guaranteeing non-repudiation of a transaction

Landscapes

  • Business, Economics & Management (AREA)
  • Accounting & Taxation (AREA)
  • Engineering & Computer Science (AREA)
  • Finance (AREA)
  • Physics & Mathematics (AREA)
  • Strategic Management (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (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 following steps: receiving a transaction request sent by a second node, wherein the transaction request carries a signature, a transaction account and transaction content; 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 in the case of the legal verification, simulating the execution of the transaction content, and recording the transaction result in the temporary ledger. By the task method provided by the embodiment of the invention, the problem of low query efficiency caused by frequent query of the local account book by the related technology can be solved.

Description

Transaction execution method, device and storage medium
Technical Field
The invention relates to the technical field of information, in particular to a transaction execution method, a transaction execution device and a storage medium.
Background
In most blockchain systems, in the process of forwarding transactions, other nodes can perform preliminary verification on the validity of the transactions, wherein the preliminary verification comprises the validity of transaction signatures and the validity verification of transaction contents, the validity of the transaction contents is verified mainly by data of a local account book, the transactions after the preliminary verification can be broadcast in the whole network, and further the blocks are generated through consensus packaging.
Under the high-frequency transaction environment, the query efficiency is reduced due to frequent query of the local account book, so that the query result is delayed and increased, and the transaction is not beneficial to quick broadcast.
Disclosure of Invention
The invention provides a transaction execution method, a transaction execution device and a storage medium, which aim to solve the problem that query efficiency is reduced due to frequent query of a local account book in the related art.
The embodiment of the invention provides a transaction execution method, which is applied to a first node and comprises the following steps: receiving a transaction request sent by a second node, wherein the transaction request carries a signature, a transaction account and transaction content; 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 under the condition of verifying the validity, simulating to execute the transaction content, and recording a transaction result in the temporary ledger.
Optionally, after simulating the execution of the transaction content, the method further includes: 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; and executing the transaction content in the block, and recording a generated transaction result in a local account book.
Optionally, the executing the transaction content in the block includes: verifying whether the block is legal; under the condition that the verification is legal, analyzing the block to generate the signature and the transaction content; verifying whether the signature and the transaction content are legal; and executing the transaction content under the condition of legality verification.
Optionally, after sending the transaction content to the consensus node, the method further includes: under the condition that a block generated by the consensus node according to the transaction content is not received within a preset time, judging whether the transaction content in the temporary account book is simulated and executed; and if the judgment result is yes, rolling back the transaction result recorded in the temporary ledger.
Optionally, after sending the transaction content to the consensus node, the method further includes: under the condition that the transaction content is not verified to be legal, judging whether the transaction content in the temporary ledger is simulated to be executed or not; and if the judgment result is yes, rolling back the transaction result recorded in the temporary ledger.
Optionally, after receiving the transaction request sent by the second node, the method further includes: and under the condition that the signature verification is legal and the transaction account is not stored in a preset list, verifying the transaction content by using the local account book.
Optionally, before verifying the transaction content by using the temporary ledger, the method further includes: acquiring information of a transaction account with a transaction frequency exceeding a preset threshold; and recording the transaction accounts with the transaction frequency exceeding a preset threshold value into the list.
The embodiment of the invention also provides a transaction execution method, which is applied to a third node and comprises the following steps: receiving a block sent by a consensus node, wherein the block carries a signature, a transaction account and transaction content; 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, judging whether the transaction content is simulated to be executed or not; and under the condition that the judgment result is negative, simulating to execute the transaction content, and recording the transaction result in the temporary account book and the local account book.
Embodiments of the present invention further provide a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the computer program implements any one of the methods in the embodiments of the present invention.
The embodiment of the present invention further provides an electronic device, which includes a memory and a processor, and the processor implements any one of the methods in the embodiments of the present invention by executing a program in the memory.
By the task method provided by the embodiment of the invention, the problem of low query efficiency caused by frequent query of the local account book in the related technology can be solved.
Drawings
FIG. 1 is a flow diagram of a transaction execution method according to an embodiment of the invention;
FIG. 2 is a flow diagram of another transaction execution method according to an embodiment of the invention;
FIG. 3 is a flow diagram of yet another transaction execution method according to an embodiment of the invention;
FIG. 4 is a flow chart of a method for a node to preliminarily verify the validity of a transaction according to an embodiment of the present invention;
FIG. 5 is a flow chart of a method for node transaction processing for a tile, according to an embodiment of the invention;
FIG. 6 is a flowchart of a method for rolling back timed-out 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 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 yet another transaction execution device according to an embodiment of the present invention.
Detailed Description
To make the objects, technical solutions and advantages of the present application more apparent, embodiments of the present application will be described in detail below with reference to the accompanying drawings. It should be noted that the embodiments and features of the embodiments in the present application may be arbitrarily combined with each other without conflict.
In addition, in the embodiments of the present invention, the words "optional" or "exemplary" are used to mean serving as an example, instance, or illustration. Any embodiment or design described as "optional" or "exemplary" in embodiments of the invention is not to be construed as preferred or advantageous over other embodiments or designs. Rather, use of the terms "optional" or "exemplary" are intended to present relevant 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 in a first node, where 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 content;
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: and in the case of the legal verification, simulating the execution of the transaction content, and recording the transaction result in the temporary ledger.
According to the method provided by the embodiment of the invention, a temporary account book is stored in a first node in the network, the first node carries out preliminary validity check on a transaction request sent by a second node through the temporary account book, and after the validity is verified, a simulated transaction result is generated in a simulation execution mode. Therefore, the work of checking the transaction content of the local account book is shared, and the node processing efficiency is improved.
Optionally, after simulating the execution of the transaction content, the method further includes: 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; and executing the transaction content in the block, and recording the generated transaction result in the local account book.
After the transaction is judged to be legal preliminarily, the first node broadcasts the transaction information, and then the transaction information is packaged through the consensus node to generate a new block; the first node receives the block generated by the consensus node, verifies the block, the signature in the block and the transaction content in the block respectively, and formally executes the transaction content under the condition of validity verification, 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 ledger book is only used for preliminary examination of transactions, and the transaction results which are actually executed and generated at last are still written into the local ledger book, so that the effectiveness of the local ledger book is guaranteed.
Optionally, the executing the transaction content in the block includes: verifying whether the block is legal; under the condition that the verification is legal, analyzing the block to generate the signature and the transaction content; verifying whether the signature and the transaction content are legal; in case of a valid authentication, the transaction content is executed.
Optionally, after sending the transaction content to the consensus node, the method further includes: under the condition that a block generated by the consensus node according to the transaction content is not received within a preset time, judging whether the transaction content in the temporary account book is simulated and executed; and if the judgment result is yes, rolling back the transaction result recorded in the temporary ledger.
Network delay may exist in the process that the first node broadcasts the transaction content or the process that the consensus node feeds back the block to the first node, if the block is not received within the preset time, the transaction is overtime, and at the moment, the cache information of the first node simulating the transaction execution and the transaction result information stored in the temporary ledger need to be rolled back and cleaned.
Optionally, after sending the transaction content to the consensus node, the method further includes: under the condition that the transaction content is not verified to be legal, judging whether the transaction content in the temporary account book is simulated to be executed or not; and if the judgment result is yes, rolling back the transaction result recorded in the temporary ledger.
Optionally, after receiving the transaction request sent by the second node, the method further includes: and under the condition that the signature verification is legal and the transaction account is not stored in a preset list, verifying the transaction content by using the local account book.
The first node manages a local account book and a temporary account book at the same time, the local account book is stored locally in a file form for 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 the list, checking through a temporary account book; and under the condition that the transaction account received by the first node is not stored in the list, checking through a local account book.
Optionally, before verifying the transaction content by using the temporary ledger, the method further includes: acquiring information of a transaction account with a transaction frequency exceeding a preset threshold; and recording the transaction accounts with the transaction frequency exceeding a preset threshold into the list.
The account information of the high-frequency transaction is recorded in the list, and all accounts in the list adopt the temporary account book to check the transaction validity, so that the transaction efficiency can be improved.
An embodiment of the present invention further provides a transaction execution method, and fig. 2 is a flowchart of another transaction execution method according to an embodiment of the present invention, which is applied in a third node, where 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 content;
s204: 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, judging whether the transaction content is simulated to be executed or not;
s206: and under the condition that the judgment result is negative, simulating to execute the transaction content, and recording the transaction result in the temporary ledger and the local ledger.
After the transaction is packaged, the consensus node generates a block and sends the block to the nodes of the whole network, wherein the block comprises the nodes where the transaction is actually to occur and the nodes where the transaction is not actually to occur. For nodes which do not actually have a transaction, the validity of the block and the signature and the transaction content carried by the block also need to be verified, the transaction content is simulated and executed, and the transaction results are recorded in the temporary ledger and the local ledger, so as to ensure that all network nodes can record the transaction.
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, the client side initializes the transaction and sends a transaction request to the node;
step 3.2, after the node receives the transaction request, starting primary verification;
step 3.3, after the node preliminarily verifies that the transaction passes, simulating to execute the transaction, and sending the transaction to the consensus node;
step 3.4, the consensus node sorts the received transactions, packs the transactions and generates a new block;
step 3.5, the consensus node sends a new block to the nodes of the whole network;
step 3.6, the node processes according to the block after consensus and updates the data in the local account book at the same time;
and 3.7, returning the final execution result to the client by the node.
Fig. 4 is a flowchart of a method for verifying the validity of a transaction primarily by a node according to an embodiment of the present invention, as shown in fig. 4, the method includes the following steps:
step 4.1, the client or other nodes broadcast and send transaction requests to the nodes, wherein the requests comprise corresponding digital signatures; the node verifies whether the signature is legal or not, if so, the verification is continued, otherwise, the transaction is returned to be invalid;
step 4.2, the node judges whether the related account data is in a list maintained by the node, if so, the temporary account book is accessed to obtain the data, and the step 4.3 is entered; otherwise, accessing the local account book and entering the step 4.4;
it should be noted that, a local account book and a temporary account book are maintained at the same time in a node in the network, the local account book is stored locally in a file form for management, and the temporary account book is stored in a memory. A list of transaction accounts is also maintained in the node, which serves a temporary ledger. The list management method may include two types:
scheme one, node self-adaptive adjustment
1) Setting temporary account book parameters according to the memory, wherein the parameters comprise the maximum number related to the account, the maximum number of cache transactions and the like;
2) and determining the priority of the account according to the account transaction data, and bringing the account into the temporary account book according to the priority. The priority can be determined according to the magnitude of tps (how many transactions per second) value traded in a certain period of time of the account.
In the first scenario, the management of the list is personalized, i.e. the list of each node in the network is different.
Scheme two, unified setting of whole network
1) The administrator configures a uniform account list at the nodes of the whole network according to the block data to ensure that the account data of different temporary accounts are consistent;
2) and the nodes generate a unified temporary account book 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 the temporary accounts of all nodes in the whole network consistent when the block heights are consistent.
Step 4.3, the node verifies whether the transaction content is legal or not according to the temporary account book, and if the transaction is legal, the transaction content is simulated and executed; otherwise, returning that the transaction is invalid;
step 4.4, the node verifies whether the transaction content is legal or not according to the local account book, and if the transaction is legal, the transaction is judged to be legal; otherwise, the returned transaction is invalid.
Fig. 5 is a flowchart of a method for processing a transaction for a node in a tile 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 generated by the package of the consensus mechanism;
step 5.2, the node verifies whether the block is legal, and if so, the transaction set is analyzed; if the transaction is illegal, returning that the transaction is invalid;
step 5.3, the node verifies whether the signature is legal, and if so, the verification is continued; if the transaction is illegal, returning that the transaction is invalid;
step 5.4, the node verifies whether the transaction content is legal:
if the transaction is legal, the transaction is normally executed, and the local account book is updated; in addition, whether the transaction of the temporary ledger is executed or not is judged, and if the transaction is executed, the cache is cleared; if not, the transaction is executed in a supplementary simulation mode;
if not, refusing the transaction execution; verifying whether the transaction is simulated and executed, if so, rolling back the transaction content to update the temporary account book information and cleaning the corresponding cache transaction; if not, the flow ends directly.
Fig. 6 is a flowchart of a rollback method for timed-out unprocessed transactions, according to an embodiment of the present invention, as shown in fig. 6, the method including the steps of:
step 6.1, the client sends a transaction request to the node;
step 6.2, the node simulates and executes transaction;
step 6.3, the node regularly verifies whether the cache transaction is not really executed after overtime, and if yes, the transaction content is rolled back to update the temporary ledger information and clear the cache information of the corresponding transaction; otherwise, continuing the caching.
The above situation may occur in the following situations: because the node fails to discard the transaction or cache an outdated transaction, the system does not pack the transaction into the block all the time, so that the cached transaction is not really executed after time out, and therefore, the transaction content must be rolled back, the temporary ledger information must be updated, and the cached information of the corresponding transaction must be cleared.
The following describes a scheme of an embodiment of the present invention with reference to a specific scenario.
Example 1 Single transfer transaction example
The list of the whole network node maintenance accounts is as follows:
serial number Account
A 6XXX1
C 6XXX3
F 6XXX6
G ...
Accounts not in the list: b account 6XXX2, D account 6XXX4, E account 6XXX 5.
The initial balance of the account A is 1000.00 yuan, the initial balance of the account B is 0.00 yuan, and the balance of the temporary account book is consistent with that of the local account book.
1) The client initiates a single account 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 request information { signature, public key, A, B, 100.00} sent by the client, firstly, verifies whether the signature is legal, and if not, returns that the transaction is invalid; if it is legal, the transaction continues; (every transaction will verify if the signature is legitimate and subsequent embodiments will not be repeated)
3) Judging whether the account A is in a list maintained by the nodes of the whole network;
4) the account A is in an account list, the node 2 uses a temporary account book to verify the validity of the transaction content, the balance of the account A is 1000.00 larger than the transfer amount of 100.00, and the transaction content is legal; the node 2 executes the transaction by using temporary ledger simulation, and the balance of the account A is 1000.00-100.00 (element) to 900.00 (element);
the account information after the node 2 simulates the execution of the transaction is as follows:
account Local ledger status Temporary ledger status
A 1000.00 900.00
B 0.00 Null
C 0.00 0.00
......
Note: account B is not in the temporary ledger list, so the temporary ledger does not store the status of account B, denoted by Nu l.
5) The transaction is broadcasted in the whole network and is subjected to consensus packaging to generate blocks;
6) and each node receives the new block which is commonly identified and packaged, analyzes the transfer transaction 1 and verifies whether the transaction content is legal or not.
Fig. 7 is a block diagram of a transaction execution method according to an embodiment of the present invention, and as shown in fig. 7, after a transaction is executed on a block, information of a corresponding node changes as follows:
the node 2, the temporary account book simulates the executed transaction, so the cache is cleared and the rollback is avoided; the local account book is booked, and the balance of the account A is 900.00 (yuan);
the node 1 and the node 3 use the temporary account book to simulate and execute the transfer transaction 1 and the local account book to keep accounts;
account balance A: 900.00, account B balance: 100.00
After the node 2 performs the transaction on the block, the account information of the node 1, the node 2 and the node 3 is as follows:
account Local ledger status Temporary ledger status
A 900.00 900.00
B 100.00 Null
C 0.00 0.00
......
Example 2 example of multiple transfer transaction
The list of the whole network node maintenance accounts is as follows:
serial number Account
A 6XXX1
C 6XXX3
F 6XXX6
G ...
Accounts not in the list: b account 6XXX2, D account 6XXX4, E account 6XXX 5.
The initial balance of the account A is 900.00 yuan, the initial balance of the account B is 100.00 yuan, and the balance of the temporary account book is consistent with that of the local account book.
The client side initiates a transfer transaction 2, a transfer transaction 3 and a transfer transaction 4 in sequence, and the transaction information is as follows:
transfer transaction 2: transferring the account A to the account B, wherein the transfer amount is 200.00 yuan;
transfer transaction 3: transferring the account A to the account C, wherein the transfer amount is 500.00 yuan;
transfer transaction 4: transferring the account C to the account B, 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. transfer transaction 2: the account A is in an account list, the node 2 uses a temporary account book to verify the validity of the content of the transaction 2, the balance 900.00 of the account A is larger than the transfer amount 200.00, and the transaction content is legal; node 2 executes the transaction using the temporary ledger simulation, with an account balance of 900.00-200.00 ═ 700.00 (yuan);
b. transfer transaction 3: the account A and the account C are both in an account list, the node 2 uses a temporary account book to verify the validity of the content of the transaction 3, the balance 700.00 of the account A is larger than the transfer amount 500.00, and the transaction content is legal; node 2 executes the transaction using the temporary ledger simulation, with account balance a of 700.00-500.00 ═ 200.00 (yuan), account balance C of 0.00+500.00 ═ 500.00 (yuan);
c. transfer transaction 4: the account C is in an account list, the node 2 uses a temporary account book to verify the validity of the content of the transaction 4, the balance of the account C is 500.00 more than the transfer amount 200.00, and the transaction content is legal; node 2 executes the transaction using the temporary ledger simulation, with a C account balance of 500.00-200.00 ═ 300.00 (yuan);
the account information after the simulation execution of the node 2 is as follows:
account Local ledger status Temporary ledger status
A 900.00 200.00
B 100.00 Null
C 0.00 300.00
......
2) The transfer transaction 2, the transfer transaction 3 and the transfer transaction 4 are broadcast by the whole network;
3) each node receives the new block packaged by the consensus, and because the consensus node does not receive the transaction 3 temporarily due to reasons such as a network and the like, 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, and the temporary account book of the node 2 simulates the transfer transaction 2, so that the cached transfer transaction 2 is cleared and does not roll back; the balance of account A is
900.00-200.00 ═ 700.00 (yuan);
at this time, the account information after the node 2 performs the transaction on the block is as follows:
account Local ledger status 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 Local ledger status Temporary ledger status
A 700.00 700.00
B 300.00 Null
C 0.00 0.00
......
Transfer transaction 4:
c. verifying the transaction content:
and the balance of the C local account of the node 2 is less than 200.00 of the transfer amount, the transaction content is illegal, and the transaction is rejected. The interim account rollback of node 2 simulates the executed transfer transaction 4, with a C account balance of 300.00+200.00 ═ 500.00 (yuan); and clearing the cache information of the transfer transaction 4 in the cache.
At this time, the account information after the node 2 rolls back is as follows:
Figure BDA0002792687460000091
Figure BDA0002792687460000101
node 1 and node 3 do not need to roll back transaction 4 since no transactions have been simulated and thus all account states of node 1 and node 3 remain unchanged.
Example 3, example rollback of timed-out unprocessed transactions
The list of the whole network node maintenance accounts is as follows:
serial number Account
A 6XXX1
C 6XXX3
F 6XXX6
G ...
Accounts not in the list: b account 6XXX2, D account 6XXX4, E account 6XXX 5.
The account information of node 2 is as follows:
account Local ledger status Temporary ledger status
A 700.00 200.00
B 300.00 Null
C 0.00 500.00
......
The account information of node 1 and node 3 is as follows:
account Local ledger status Temporary ledger status
A 700.00 700.00
B 300.00 Null
C 0.00 0.00
......
Assume that transaction 3 eventually times out, i.e., is not recorded in a block for a period of time set by the system.
At this point, node 2 needs to roll back the transaction and then clear the transaction since only node 2 has emulated the execution. The contents of transfer transaction 3 are reviewed again: transferring the account A to the account C, wherein the transfer amount is 500.00 yuan;
since A and C are on the list, after the transaction is rolled back, account A is +500 yuan, and account C is-500 yuan
The account information of node 2 is as follows:
account Local ledger status 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 the states of node 1, node 2 and node 3 are consistent at this time.
And finally, clearing the transaction in the cache.
An embodiment of the present invention further provides a transaction execution apparatus, which is applied in the first node, and fig. 8 is a block diagram of a transaction execution apparatus according to an embodiment of the present invention, which includes 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 a 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 by 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 execution of the transaction content and record a transaction result in the temporary ledger if the verification is legal.
Optionally, the apparatus further includes a sending module, a second receiving module, and a second executing module, where the sending module is configured to send the transaction content to the consensus node; the second receiving module is configured to receive a block generated by the consensus node according to the transaction content, where the block carries the signature and the transaction content; the second execution module is used for executing the transaction content in the block and recording the generated transaction result in the local account book.
Optionally, the second execution module is specifically configured to verify whether the block is legal; under the condition that the verification is legal, analyzing the block to generate the signature and the transaction content; verifying whether the signature and the transaction content are legal; in case of a valid authentication, the transaction content is executed.
Optionally, the apparatus further includes a first determining module, configured to determine, after the transaction content is sent to the consensus node, whether the transaction content in the temporary ledger is executed in a simulated manner when a block generated by the consensus node according to the transaction content is not received within a preset time; and if the judgment result is yes, rolling back the transaction result recorded in the temporary ledger.
Optionally, the apparatus further includes a second determining module, configured to determine, after sending the transaction content to the consensus node, whether the transaction content in the temporary ledger is executed in a simulated manner under the condition that the transaction content is not validated; and if the judgment result is yes, rolling back the transaction result recorded in the temporary ledger.
Optionally, the apparatus further includes a second verification module, configured to verify the transaction content by using the local ledger when the signature verification is legal and the transaction account is not stored in a preset list after receiving the transaction request sent by the second node.
Optionally, the device further includes a recording module, configured to obtain information of a transaction account with a transaction frequency exceeding a preset threshold before the temporary ledger is used to verify the transaction content; and recording the transaction accounts with the transaction frequency exceeding a preset threshold into the list.
Fig. 9 is a block diagram of another transaction execution apparatus according to an embodiment of the present invention, which includes a receiving module 92, a determining module 94, and an executing module 96, wherein,
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 executed in a simulated manner 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;
and the execution module 96 is used for simulating and executing the transaction content and recording the transaction result in the temporary ledger and the local ledger under the condition that the judgment result is negative.
In another embodiment of the invention, a transaction execution device is provided, and fig. 10 is a block diagram of another transaction execution device according to an embodiment of the invention, which includes a roster 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 service for the temporary account book;
the temporary ledger module 104 is configured to read a local ledger file into a memory to form a temporary ledger file, and perform preliminary verification of a transaction;
the local ledger module 106 is configured to store a local ledger file in a file form to a local for management;
the communication module 108 is used for interaction between nodes.
The embodiment of the invention also provides an electronic device, which comprises a processor and a memory; the number of processors in the electronic device may be one or more, and the memory, which is a computer-readable storage medium, may be used to store a computer-executable program. The processor executes various functional applications of the electronic device and data processing by executing software programs and instructions stored in the memory, namely, the method in any one of the above embodiments is realized.
Embodiments of the present application also provide a storage medium containing computer-executable instructions, which when executed by a computer processor implement the method in any of the above embodiments.
Optionally, the processor implements a transaction execution method by executing the instructions, the method is applied to the first node and includes:
s1, receiving a transaction request sent by a second node, wherein the transaction request carries a signature, a transaction account and transaction content;
s2, when the signature verification is legal and the transaction account is stored in a preset list, the transaction content is verified by using a temporary account book;
and S3, simulating the execution of the transaction content and recording the transaction result in the temporary ledger under the condition of verifying the validity.
The above are merely exemplary embodiments of the present application, and are 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, for example in a processor entity, or by hardware, or by 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 code or object code written in any combination of one or more programming languages.
Any logic flow block diagrams 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 disks, DVDs, or CD discs), 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 has provided by way of exemplary and non-limiting examples a detailed description of exemplary embodiments of the present application. Various modifications and adaptations to the foregoing embodiments may become apparent to those skilled in the relevant arts in view of the following drawings and the appended claims without departing from the scope of the invention. Therefore, the proper scope of the invention is to be determined according to the claims.

Claims (10)

1. A transaction execution method applied to a first node is characterized by comprising the following steps:
receiving a transaction request sent by a second node, wherein the transaction request carries a signature, a transaction account and transaction content;
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 under the condition of verifying the validity, simulating to execute the transaction content, and recording a transaction result in the temporary ledger.
2. The method of claim 1, after simulating execution of the transaction content, further comprising:
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;
and executing the transaction content in the block, and recording a generated transaction result in a local account book.
3. The method of claim 2, wherein said executing said transactional content in said block comprises:
verifying whether the block is legal;
under the condition that the verification is legal, analyzing the block to generate the signature and the transaction content;
verifying whether the signature and the transaction content are legal;
and executing the transaction content under the condition of legality verification.
4. The method of claim 2 or 3, after sending the transaction content to a consensus node, further comprising:
under the condition that a block generated by the consensus node according to the transaction content is not received within a preset time, judging whether the transaction content in the temporary account book is simulated and executed;
and if the judgment result is yes, rolling back the transaction result recorded in the temporary ledger.
5. The method of claim 3, after sending the transaction content to a consensus node, further comprising:
under the condition that the transaction content is not verified to be legal, judging whether the transaction content in the temporary ledger is simulated to be executed or not;
and if the judgment result is yes, rolling back the transaction result recorded in the temporary ledger.
6. A method according to claim 2 or 3, further comprising, after receiving the transaction request sent by the second node:
and under the condition that the signature verification is legal and the transaction account is not stored in a preset list, verifying the transaction content by using the local account book.
7. The method of any of claims 1-3, further comprising, prior to validating the transaction content using a temporary ledger:
acquiring information of a transaction account with a transaction frequency exceeding a preset threshold;
and recording the transaction accounts with the transaction frequency exceeding a preset threshold value into the list.
8. A transaction execution method applied in a third node, comprising:
receiving a block sent by a consensus node, wherein the block carries a signature, a transaction account and transaction content;
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, judging whether the transaction content is simulated to be executed or not;
and under the condition that the judgment result is negative, simulating to execute the transaction content, and recording the transaction result in the temporary account book and the local account book.
9. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program which, when executed by a processor, implements the method of any one of claims 1-7 or the method of claim 8.
10. An electronic device comprising a memory and a processor, wherein the processor implements the method of any one of claims 1-7 or the method of claim 8 by executing a computer program in the memory.
CN202011320377.7A 2020-11-23 2020-11-23 Transaction execution method, device and storage medium Pending CN112488832A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011320377.7A CN112488832A (en) 2020-11-23 2020-11-23 Transaction execution method, device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011320377.7A CN112488832A (en) 2020-11-23 2020-11-23 Transaction execution method, device and storage medium

Publications (1)

Publication Number Publication Date
CN112488832A true CN112488832A (en) 2021-03-12

Family

ID=74933491

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011320377.7A Pending CN112488832A (en) 2020-11-23 2020-11-23 Transaction execution method, device and storage medium

Country Status (1)

Country Link
CN (1) CN112488832A (en)

Citations (2)

* Cited by examiner, † Cited by third party
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
US20190140822A1 (en) * 2016-12-30 2019-05-09 Cloudminds (Shenzhen) Robotics Systems Co., Ltd. Block chain permission control method, device, and node apparatus

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190140822A1 (en) * 2016-12-30 2019-05-09 Cloudminds (Shenzhen) Robotics Systems Co., Ltd. Block chain permission control method, device, and node apparatus
CN109345251A (en) * 2018-08-24 2019-02-15 深圳壹账通智能科技有限公司 Negotiable block chain method of commerce, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
EP3610436B1 (en) Rapid distributed consensus on blockchain
US12093247B2 (en) Blockchain system and method
Wüst et al. ACE: Asynchronous and concurrent execution of complex smart contracts
CN109886681A (en) Block chain common recognition method and common recognition system
CN110049087B (en) Credibility verification method, system, device and equipment of alliance chain
CN111880746A (en) Method and device for writing service data into block chain system
CN113568981B (en) Transaction data processing method, device, equipment and medium
CN112583811B (en) Wallet finding method, equipment and storage medium
KR20180125009A (en) Data caching method and apparatus
US11403281B2 (en) Parallel blockchain processing
CN102916935A (en) Site content pickup-preventing method
Pedone et al. Byzantine fault-tolerant deferred update replication
CN113760976B (en) Service processing method, device, equipment and storage medium
CN109710695A (en) The identification of transactions requests validity and initiating method, device, equipment and medium
CN111488626A (en) Data processing method, device, equipment and medium based on block chain
CN112887436B (en) Consensus method, consensus node and block chain system of pipeline mode
CN107277108B (en) Method, device and system for processing messages at nodes of block chain
CN112488832A (en) Transaction execution method, device and storage medium
CN116977067A (en) Block chain-based data processing method, device, equipment and readable storage medium
CN116542668A (en) Block chain-based data processing method, equipment and readable storage medium
CN112991067A (en) Block chain consensus method, device and system
CN106372178A (en) Transaction file processing method and device as well as server
CN115941191B (en) Generation and verification method for non-consensus blocks in block chain and witness nodes
CN108156195A (en) A kind of business datum inspection method and system
CN116521051A (en) Data processing method and device

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