Transaction processing method and device, electronic equipment and storage medium

By introducing stand-alone node instances and transaction pools into the blockchain system nodes, off-chain transactions are directly processed locally, the problems of high off-chain transaction costs and low information interaction efficiency are solved, and efficient off-chain transaction processing is achieved.

CN119228534APending Publication Date: 2024-12-31TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310786355.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-29
Publication Date
2024-12-31

AI Technical Summary

Technical Problem

The blockchain system is costly and requires additional off-chain trading systems when processing off-chain transactions, and nodes need to interact with off-chain trading systems, resulting in long data communication time and low efficiency.

Method used

Introduce stand-alone node instances, local ledgers and chain transaction pools into nodes of the blockchain system, receive transaction data sent by the terminal and store them in the chain transaction pool. If it is an off-chain transaction, it will be stored in the local transaction pool. The node is used as a The transaction recipient generates off-chain transaction blocks and executes them, and the results are stored in the local ledger, avoiding the need to set up additional off-chain transaction systems and reducing information interaction.

Benefits of technology

It realizes efficient processing of off-chain transactions within the blockchain system, saves the cost of setting up off-chain transaction systems, reduces data communication time, and improves the efficiency of off-chain transactions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119228534A_ABST
    Figure CN119228534A_ABST
Patent Text Reader

Abstract

The invention discloses a transaction processing method and device, electronic equipment and a storage medium. The embodiment of the invention relates to the technical field of block chains and the like. The method comprises the following steps: in response to receiving target transaction data sent by a terminal, storing the target transaction data in a chain transaction pool; if the transaction type of the target transaction data is under-chain transaction, storing the target transaction data in a local transaction pool; obtaining to-be-processed transaction data under a target chain from a local transaction pool; if the node is a transaction receiver of the target off-chain transaction data, generating an off-chain transaction block according to the target off-chain transaction data; calling the stand-alone node instance to execute the under-chain transaction block to obtain an under-chain transaction result; and storing the off-chain transaction result and the off-chain transaction block in a local account book. According to the method and the device, an off-chain transaction system does not need to be arranged, the cost of arranging the off-chain transaction system is saved, meanwhile, information interaction with the off-chain transaction system is not needed, and the efficiency of off-chain transaction is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of blockchain technology, and more specifically, to a transaction processing method, device, electronic device and storage medium. Background Art

[0002] With the rapid development of blockchain technology, blockchain technology can now be applied to a variety of transaction scenarios. For example, the blockchain system can be used to execute various payment transactions, shopping transactions, and transfer transactions sent by the terminal. However, in some specific scenarios, when the transaction sent by the terminal is an off-chain transaction, the blockchain system cannot process the off-chain transaction.

[0003] In order to realize off-chain transactions, a specific off-chain transaction system can be set up outside the blockchain system. When a node in the blockchain receives an off-chain transaction sent by a terminal, the node sends the off-chain transaction to the off-chain transaction system, which processes the off-chain transaction. However, the cost of processing off-chain transactions using this method is high. Summary of the invention

[0004] In view of this, the embodiments of the present application propose a transaction processing method, device, electronic device and storage medium.

[0005] In a first aspect, an embodiment of the present application provides a transaction processing method for a node in a blockchain system, the node comprising a stand-alone node instance, a local ledger, a local transaction pool and a chain transaction pool; the local transaction pool is used to store off-chain transaction data; the chain transaction pool is used to store on-chain transaction data; the method comprises: in response to receiving target transaction data sent by a terminal, storing the target transaction data in the chain transaction pool; if the transaction type of the target transaction data is an off-chain transaction, storing the target transaction data in the local transaction pool; obtaining the target off-chain transaction data to be processed from the local transaction pool; if the node is the transaction recipient of the target off-chain transaction data, generating an off-chain transaction block according to the target off-chain transaction data; calling the stand-alone node instance to execute the off-chain transaction block to obtain the off-chain transaction result; storing the off-chain transaction result and the off-chain transaction block in the local ledger.

[0006] In a second aspect, an embodiment of the present application provides a transaction processing device for a node in a blockchain system, the node comprising a stand-alone node instance, a local account book, a local transaction pool and a chain transaction pool; the local transaction pool is used to store off-chain transaction data; the chain transaction pool is used to store on-chain transaction data; the device comprises: a response module, used to store the target transaction data in the chain transaction pool in response to receiving the target transaction data sent by the terminal; a data storage module, used to store the target transaction data in the local transaction pool if the transaction type of the target transaction data is an off-chain transaction; an acquisition module, used to obtain the target off-chain transaction data to be processed from the local transaction pool; a block generation module, used to generate an off-chain transaction block according to the target off-chain transaction data if the node is the transaction recipient of the target off-chain transaction data; an execution module, used to call the stand-alone node instance to execute the off-chain transaction block to obtain the off-chain transaction result; a result storage module, used to store the off-chain transaction result and the off-chain transaction block in the local account book.

[0007] Optionally, the node also includes a consensus node instance and a blockchain; the device also includes an on-chain transaction module, which is used to obtain target on-chain transaction data from a chain transaction pool; generate an on-chain transaction block according to the target on-chain transaction data; call the consensus node instance to determine the transaction result block according to the on-chain transaction block, and broadcast the on-chain transaction block to other nodes in the blockchain system; call the consensus node instance to reach a consensus on the transaction result block in the blockchain system, and write the transaction result block into the node's blockchain if the consensus is passed.

[0008] Optionally, the node includes a contract virtual machine; the execution module is also used to call a single-machine node instance to execute an off-chain transaction block through the contract virtual machine to obtain an off-chain transaction result.

[0009] Optionally, the node also includes an executor; the execution module is also used to call the stand-alone node instance to create a transaction process through the executor; call the contract virtual machine through the transaction process to execute the off-chain transaction block to obtain the off-chain transaction result.

[0010] Optionally, the device also includes a broadcast module, which is used to broadcast the target off-chain transaction data to other nodes in the blockchain system if the node is not a transaction recipient of the target off-chain transaction data.

[0011] Optionally, the target off-chain transaction data includes an encrypted encryption key, which is encrypted by the public key of the terminal; the block generation module is also used to decrypt the encrypted encryption key by the private key of the node; if the encrypted encryption key is decrypted successfully, the node is determined to be the transaction recipient of the target off-chain transaction data; if the encrypted encryption key fails to be decrypted, it is determined that the node is not the transaction recipient of the target off-chain transaction data.

[0012] Optionally, the target off-chain transaction data also includes encrypted business data, which is encrypted by an encryption key; the block generation module is also used to obtain the encryption key obtained by decrypting the encrypted encryption key if the node is the transaction recipient of the target off-chain transaction data; decrypt the encrypted business data according to the encryption key to obtain decrypted transaction data; and generate an off-chain transaction block according to the decrypted transaction data.

[0013] Optionally, the target transaction data also includes unencrypted transaction recipient information; the block generation module is further used to generate an off-chain transaction block according to the target off-chain transaction data if it is determined that the transaction recipient of the target off-chain transaction data is a node based on the unencrypted transaction recipient information.

[0014] Optionally, the broadcast module is also used to send the target off-chain transaction data to the target node where the transaction recipient indicated by the unencrypted transaction recipient information is located if it is determined based on the unencrypted transaction recipient information that the transaction recipient of the target off-chain transaction data is not a node.

[0015] Optionally, the response module is further used to verify the target digital signature corresponding to the target transaction data in response to receiving the target transaction data sent by the terminal; if the target digital signature verification is successful, the target transaction data is stored in the chain transaction pool.

[0016] Optionally, the data storage module is further used to obtain a transaction type field from the target transaction data; and determine the transaction type of the target transaction data according to the transaction type field.

[0017] In a third aspect, an embodiment of the present application provides an electronic device, including a processor and a memory; one or more programs are stored in the memory and configured to be executed by the processor to implement the above method.

[0018] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a program code is stored, wherein the above method is executed when the program code is executed by a processor.

[0019] In a fifth aspect, an embodiment of the present application provides a computer program product or a computer program, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device performs the above method.

[0020] A transaction processing method, device, electronic device and storage medium provided in an embodiment of the present application. In the present application, the nodes of the blockchain system include a stand-alone node instance, a local account book, a local transaction pool and a chain transaction pool. The node can store target transaction data whose transaction type is an off-chain transaction in the local transaction pool of the node, and then obtain the target off-chain transaction data to be processed in the local transaction pool, call the stand-alone node instance in the node to execute the off-chain transaction block corresponding to the target off-chain transaction data, and store the off-chain transaction result and the off-chain transaction block in the local account book, so that the nodes in the blockchain system can execute off-chain transactions, and there is no need to set up an additional off-chain transaction system, saving the cost of arranging the off-chain transaction system. At the same time, the nodes in the blockchain do not need to interact with the off-chain transaction system for information, which greatly reduces the data communication time and improves the efficiency of off-chain transactions. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0022] Figure 1 A schematic diagram of the architecture of a blockchain system applicable to an embodiment of the present application is shown;

[0023] Figure 2 A schematic diagram of a data structure of a blockchain applicable to an embodiment of the present application is shown;

[0024] Figure 3 A schematic diagram of a new block generation process applicable to an embodiment of the present application is shown;

[0025] Figure 4 A flow chart of a transaction processing method proposed in one embodiment of the present application is shown;

[0026] Figure 5 A flowchart of a transaction processing method proposed in another embodiment of the present application is shown;

[0027] Figure 6 A flow chart of a transaction processing method proposed in another embodiment of the present application is shown;

[0028] Figure 7 A flow chart of a transaction processing method proposed in another embodiment of the present application is shown;

[0029] Figure 8 A schematic diagram of the structure of a node in an embodiment of the present application is shown;

[0030] Fig. 9 A schematic diagram showing a transaction processing process in an embodiment of the present application is shown;

[0031] Fig.10 A schematic diagram showing another transaction processing process in an embodiment of the present application is shown;

[0032] Fig.11 A block diagram of a transaction processing device proposed in one embodiment of the present application is shown;

[0033] Fig.12 A structural block diagram of an electronic device for executing a transaction processing method according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0034] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. According to the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0035] In the following description, the terms "first\second" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0036] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0037] It should be noted that the "multiple" mentioned in this article refers to two or more. "And / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.

[0038] It should also be noted that in the embodiments of the present application, if the transaction data is the transaction data of a user, the acquisition of the transaction data requires the user's permission or consent, and the collection, use, processing and storage of the transaction data must comply with the regulations of the region where the transaction data is located.

[0039] The present application discloses a transaction processing method, device, electronic device and storage medium, which involve blockchain technology, etc.

[0040] See also Figure 1 The blockchain system shown, the blockchain system 100 refers to a blockchain network system for sharing data between nodes, and the blockchain system 100 may include multiple consensus nodes 101. Each consensus node 101 can receive input information when performing normal work, and maintain the shared data in the blockchain based on the received input information. In order to ensure the intercommunication of information within the blockchain, there can be an information connection between each consensus node 101 in the blockchain, and information can be transmitted between the consensus nodes 101 through the above information connection. For example, when any consensus node 101 in the blockchain receives input information, other consensus nodes 101 in the blockchain obtain the input information according to the consensus algorithm, and store the input information as data in the shared data, so that the data stored on all consensus nodes 101 in the blockchain are consistent.

[0041] Each consensus node 101 in the blockchain has a corresponding consensus node identifier, and each consensus node 101 in the blockchain can store the consensus node identifiers of other consensus nodes 101 in the blockchain, so that the generated blocks can be broadcast to other consensus nodes 101 in the blockchain according to the consensus node identifiers of other consensus nodes 101. Each consensus node 101 can maintain a consensus node identifier list as shown in the following table, and store the consensus node name and consensus node identifier in the consensus node identifier list accordingly. Among them, the consensus node identifier can be an IP (Internet Protocol, a protocol for interconnection between networks) address and any other information that can be used to identify the consensus node. Table 1 only takes the IP address as an example for explanation.

[0042] Consensus node name Consensus node identification Consensus Node 1 117.114.151.174 Consensus Node 2 117.116.189.145 … … Consensus Node N 119.123.789.258

[0043] Each consensus node 101 in the blockchain system stores an identical blockchain. The blockchain consists of multiple blocks. Figure 2 The blockchain consists of multiple blocks. The genesis block includes a block header and a block body. The block header stores the input information characteristic value, version number, timestamp and difficulty value, and the block body stores the input information; the next block of the genesis block takes the genesis block as the parent block, and the next block also includes a block header and a block body. The block header stores the input information characteristic value of the current block, the block header characteristic value, version number, timestamp and difficulty value of the parent block, and so on, so that the block data stored in each block in the blockchain is associated with the block data stored in the parent block, ensuring the security of the input information in the block.

[0044] When generating each block in the blockchain, see Figure 3, when the consensus node 101 where the blockchain is located receives the input information, it verifies the input information. After the verification is completed, the input information is stored in the memory pool, and the hash tree used to record the input information is updated; then, the update timestamp is updated to the time when the input information is received, and different random numbers are tried, and the eigenvalue calculation is performed multiple times, so that the calculated eigenvalue can satisfy the following formula:

[0045] SHA256(SHA256(version+prev_hash+merkle_root+ntime+nbits+x)) <TARGET

[0046] Among them, SHA256 is the eigenvalue algorithm used to calculate the eigenvalue; version (version number) is the version information of the relevant block protocol in the blockchain; prev_hash is the block header eigenvalue of the parent block of the current block; merkle_root is the eigenvalue of the input information; ntime is the update time of the update timestamp; nbits is the current difficulty, which is a fixed value within a period of time and is determined again after exceeding the fixed time period; x is a random number; TARGET is the eigenvalue threshold, which can be determined based on nbits.

[0047] In this way, when the random number that satisfies the above formula is calculated, the information can be stored accordingly, the block header and block body can be generated, and the current block can be obtained. Subsequently, the consensus node 101 where the blockchain is located sends the newly generated block to other consensus nodes in the blockchain where it is located according to the consensus node identifiers of other consensus nodes in the blockchain, and other consensus nodes verify the newly generated block and add the newly generated block to the blockchain stored thereafter.

[0048] See also Figure 4 , Figure 4 A flowchart of a transaction processing method proposed in one embodiment of the present application is shown. The method can be applied to a node in a blockchain system. The method includes:

[0049] S110 . In response to receiving the target transaction data sent by the terminal, storing the target transaction data in a chain transaction pool.

[0050] The blockchain system includes multiple nodes, which may include blockchains, consensus node instances, stand-alone node instances, local ledgers, local transaction pools, and chain transaction pools. The local transaction pool is used to store off-chain transaction data; the chain transaction pool is used to store on-chain transaction data.

[0051] Off-chain transaction data refers to data for off-chain transactions. Off-chain transactions refer to transactions that do not need to be conducted in the blockchain. The relevant data of the transaction (such as transaction data and transaction results, etc.) does not need to be saved in the blockchain of the node; off-chain transactions can be, for example, cost accounting, bargaining process, process negotiation, signing of additional agreements, etc. These transactions are consistent with the design of traditional institutional dedicated line systems, but the final agreements reached by these exchanges may need to be open and transparent, which is consistent with the characteristics of the blockchain. Therefore, through the method of this application, it can be processed by the nodes in the blockchain system in the form of off-chain transactions.

[0052] On-chain transaction data refers to data for on-chain transactions. On-chain transactions refer to transactions that need to be conducted in the blockchain. The relevant data of the transaction (such as transaction data and transaction results, etc.) needs to be saved in the node's blockchain.

[0053] A consensus node instance may refer to a program for implementing on-chain transactions, which may include smart contracts, instruction sets for executing transactions based on smart contracts, instruction sets for communicating with the blockchain, and consensus algorithms for reaching consensus with other nodes, etc. A stand-alone node instance may refer to a program for implementing off-chain transactions, which may include smart contracts, instruction sets for executing transactions based on smart contracts, and instruction sets for communicating with the blockchain, etc.

[0054] The local ledger is used to store transaction-related data of off-chain transactions executed in the node; the blockchain may refer to a blockchain ledger, which is used to store transaction-related data of on-chain transactions executed in the node.

[0055] If the blockchain system includes transaction nodes and blockchain observer nodes, the method of the present application can be executed by the transaction nodes.

[0056] A transaction node refers to a node that runs in a blockchain system and is used to execute transactions and reach consensus. A blockchain observer node refers to a node that runs in a blockchain system and is used to implement an observation function. The observation function can refer to observing and monitoring transaction and block information in the blockchain system and forwarding this information to other transaction nodes. Blockchain observer nodes usually do not participate in the consensus process, but instead obtain information and provide services by observing the blockchain network. Blockchain observer nodes can help users observe transactions, check balances, observe network status, etc., and can also help developers develop and test blockchain applications.

[0057] A transaction node can have multiple isolated storage spaces, with one storage space allocated to the chain transaction pool, one storage space allocated to the local transaction pool, one storage space allocated to the local ledger, and one storage space allocated to the blockchain.

[0058] The terminal can generate target transaction data according to the target transaction, and send the target transaction data to the node in the blockchain system. The target transaction may refer to a transaction request, which is equivalent to the computer term transaction. The transaction includes the operations that need to be submitted to the node in the blockchain system, and the corresponding transaction results. It does not only refer to transactions in a business context. In view of the conventional use of the term "transaction" in blockchain technology, the embodiments of the present invention follow this practice. For example, transactions may include deployment transactions and invocation transactions. Deployment transactions are used to deploy smart contracts to nodes in the blockchain and prepare them to be called; invocation transactions are used to query (i.e., read operations) or update (i.e., write operations, including addition, deletion, and modification) the status database in the ledger.

[0059] The target transaction data may include the specific content of the target transaction, such as the two parties involved in the target transaction, the subject of the transaction (such as the transaction amount, etc.). For example, if the target transaction is a transfer of 100 yuan from A to B, the target transaction data may include data such as the transfer of 100 yuan from A to B, the account balance of A before and after the transfer, and the account balance of B before and after the transfer.

[0060] Any node in the blockchain system can store the target transaction data in its own chain transaction pool in response to receiving the target transaction data sent by the terminal.

[0061] S120: If the transaction type of the target transaction data is an off-chain transaction, the target transaction data is stored in a local transaction pool.

[0062] After the node stores the target transaction data in the chain transaction pool in the node, it can determine the transaction type of the target transaction data, which includes on-chain transactions and off-chain transactions. If the transaction type of the target transaction data is an off-chain transaction, the target transaction data is taken from the chain transaction pool in the node and stored in the local transaction pool in the node.

[0063] As an implementation method, the target transaction data may include a transaction type field, and the transaction type field may be obtained from the target transaction data, and the transaction type of the target transaction data may be determined according to the transaction type field. The transaction type field refers to a field used to indicate the transaction type of the target transaction data, and the transaction type field may be in the form of an identifier or a symbol. For example, when the value of the transaction type field is 1, it indicates that the transaction type is an on-chain transaction, and when the value of the transaction type field is 0, it indicates that the transaction type is an off-chain transaction.

[0064] S130. Obtain the target off-chain transaction data to be processed from the local transaction pool.

[0065] Based on the processing of steps S110-S120 above, it can be ensured that the transaction data stored in the local transaction pool on the node are all transaction data of off-chain transactions, and the transaction data of off-chain transactions is also called off-chain transaction data. In this application, the current off-chain transaction data to be processed is called target off-chain transaction data.

[0066] The transaction data to be processed can be obtained from the local transaction pool of the node as the target off-chain transaction data. When the local transaction pool of the node stores only the target transaction data, the target transaction data is obtained as the target off-chain transaction data; when the local transaction pool of the node stores the target transaction data and other unexecuted off-chain transaction data, the target transaction data and all other unexecuted transaction data can be obtained as the target off-chain transaction data, or part of other unexecuted transaction data and the target transaction data can be obtained as the target off-chain transaction data.

[0067] Among them, other unexecuted off-chain transaction data may be off-chain transaction data received before receiving the target transaction data, and other unexecuted off-chain transaction data and the target transaction data may come from the same terminal or from different terminals.

[0068] It should also be noted that off-chain transactions involve transaction recipients. The transaction data of each off-chain transaction needs to be sent to the corresponding transaction recipient, and the transaction recipient of the off-chain transaction will process the transaction based on the transaction data. Among the two parties involved in the transaction, one party is called the transaction initiator and the other party is called the transaction recipient. For example, if a transaction is a transfer from account A to account B, the party B where account A is located is the transaction initiator, and the party where account B is located is the transaction recipient.

[0069] When the target off-chain transaction data includes data corresponding to multiple transactions, the transaction recipients of the multiple transactions are all the same node, that is, when obtaining the target off-chain transaction data to be processed from the local transaction pool, the transaction data with the same transaction recipient will be obtained as the target off-chain transaction data. The different transaction data of the transaction recipients can be aggregated separately to obtain the corresponding multiple target off-chain transaction data, and then the subsequent transaction processing steps are performed on one target off-chain transaction data each time.

[0070] S140: If the node is the transaction recipient of the target off-chain transaction data, generate an off-chain transaction block according to the target off-chain transaction data.

[0071] After obtaining the target off-chain transaction data, it can be determined whether the node is the transaction recipient of the target off-chain transaction data. In the case where the node is the transaction recipient of the target off-chain transaction data, the node generates an off-chain transaction block based on the target off-chain transaction data.

[0072] As an implementation method, the target transaction data may include transaction recipient information. If the transaction recipient information is unencrypted, whether the node is the transaction recipient of the target off-chain transaction data is directly determined based on the transaction recipient information. Specifically: if it is determined that the transaction recipient information indicates that the node is the transaction recipient of the target off-chain transaction data, the node is determined to be the transaction recipient of the target off-chain transaction data; if it is determined that the transaction recipient information indicates that the node is not the transaction recipient of the target off-chain transaction data, the node is determined not to be the transaction recipient of the target off-chain transaction data.

[0073] Among them, the transaction recipient information may refer to the node name, node identifier, and node IP address of the transaction recipient. If the transaction recipient information matches the node information, it is determined that the transaction recipient information indicates that the node is the transaction recipient of the target off-chain transaction data. If the transaction recipient information does not match the node information, it is determined that the transaction recipient information indicates that the node is the transaction recipient of the target off-chain transaction data. For example, if the transaction recipient information is an IP address, when the transaction recipient information is the same as the node IP address, it is determined that the transaction recipient information matches the node information; for another example, if the transaction recipient information is a node name, when the transaction recipient information is the same as the node name, it is determined that the transaction recipient information matches the node information.

[0074] As another implementation method, the target off-chain transaction data includes an encrypted encryption key, which is encrypted by the public key of the terminal, that is, encrypted by the public key of the transaction initiator; the encrypted encryption key can be decrypted by the private key of the node; if the encrypted encryption key is decrypted successfully, the node is determined to be the transaction recipient of the target off-chain transaction data; if the encrypted encryption key fails to be decrypted, it is determined that the node is not the transaction recipient of the target off-chain transaction data.

[0075] The terminal can send a public key acquisition request to the transaction recipient. After the node as the transaction recipient receives the public key acquisition request, the node can generate a corresponding private key and public key (which can be determined by an asymmetric encryption algorithm) and send the public key to the terminal. The terminal encrypts the encryption key by using the public key, and obtains the target transaction data based on the encrypted encryption key and the target transaction. The transaction data stored in the local transaction pool of the node itself is obtained in the same way as the target transaction data. Therefore, the target off-chain transaction data obtained by the local transaction pool also includes the encrypted encryption key.

[0076] After the node obtains the target off-chain transaction data, it decrypts the encrypted encryption key according to the local private key. If the decryption is successful, it means that the encrypted encryption key is encrypted by the public key corresponding to the private key stored by the node itself, and it is determined that the public key used by the terminal sending the target off-chain transaction data is a pair with the private key stored by the node itself. Therefore, it is determined that the node is the transaction recipient of the target off-chain transaction data. Similarly, if the decryption fails, it means that the encrypted encryption key is not encrypted by the public key corresponding to the private key stored by the node itself, and it is determined that the public key used by the terminal sending the target off-chain transaction data is not a pair with the private key stored by the node itself. Therefore, it is determined that the node is not the transaction recipient of the target off-chain transaction data.

[0077] If it is the transaction recipient of the target off-chain transaction data, a block is generated according to the target off-chain transaction data, and the generated block is used as the off-chain transaction block. The off-chain transaction block may include an off-chain transaction block header and an off-chain transaction block body. The off-chain transaction block header may include information such as a timestamp, a difficulty target, and a random number. The off-chain transaction block body may include the target off-chain transaction data itself and the hash value corresponding to the target off-chain transaction data.

[0078] S150. Call the stand-alone node instance to execute the off-chain transaction block and obtain the off-chain transaction result.

[0079] After generating an off-chain transaction block according to the target off-chain transaction data, the off-chain transaction block is executed through a stand-alone node instance to obtain an off-chain transaction result. The off-chain transaction result can be obtained by executing a transaction according to the target off-chain transaction data in the off-chain transaction block body included in the off-chain transaction block through a stand-alone node instance.

[0080] As an implementation method, the node may also include a contract virtual machine, which can call a single-machine node instance to execute off-chain transaction blocks through the contract virtual machine to obtain off-chain transaction results. On the nodes of the blockchain system, the nodes complete operations that require consensus by running smart contracts deployed on the blockchain, and the corresponding contract virtual machine provides the operating environment for the smart contract.

[0081] A smart contract is a computer protocol designed to communicate, verify or execute contracts in an information-based manner. Smart contracts allow for trusted transactions without a third party, which are observable and irreversible. The purpose of smart contracts is to provide a security method that is superior to traditional contracts and to reduce other transaction costs associated with contracts.

[0082] As another implementation method, the node may also include a contract virtual machine and an executor. The executor is used to manage the transaction process. The node may call a stand-alone node instance to create a transaction process through the executor; the contract virtual machine is called through the transaction process to execute the off-chain transaction block to obtain the off-chain transaction result.

[0083] S160. Store the off-chain transaction results and off-chain transaction blocks in the local account book.

[0084] After the node completes the transaction of the target off-chain transaction data, the off-chain transaction results and off-chain transaction blocks corresponding to the target off-chain transaction data can be stored in the local account book, so as to manage the various completed off-chain transactions through the local account book. That is, the off-chain transaction results and off-chain transaction blocks do not need to be stored in the node's blockchain.

[0085] In this embodiment, the nodes of the blockchain system include a stand-alone node instance, a local account book, a local transaction pool and a chain transaction pool. The node can store target transaction data whose transaction type is an off-chain transaction in the local transaction pool of the node, and then obtain the target off-chain transaction data to be processed in the local transaction pool, call the stand-alone node instance in the node to execute the off-chain transaction block corresponding to the target off-chain transaction data, and store the off-chain transaction result and the off-chain transaction block in the local account book, so that the nodes in the blockchain system can execute off-chain transactions, and there is no need to set up an additional off-chain transaction system, saving the cost of arranging the off-chain transaction system. At the same time, the nodes in the blockchain do not need to interact with the off-chain transaction system for information, which greatly reduces the data communication time and improves the efficiency of off-chain transactions.

[0086] See also Figure 5 , Figure 5 A flowchart of a transaction processing method proposed in another embodiment of the present application is shown. The method can be applied to a node in a blockchain system. The method includes:

[0087] S210. In response to receiving the target transaction data sent by the terminal, the target transaction data is stored in the chain transaction pool; if the transaction type of the target transaction data is an off-chain transaction, the target transaction data is stored in the local transaction pool; and the target off-chain transaction data to be processed is obtained from the local transaction pool.

[0088] S220. Decrypt the encrypted encryption key using the private key of the node; if the encrypted encryption key is decrypted successfully, determine that the node is the transaction recipient of the target off-chain transaction data; if the encrypted encryption key is decrypted unsuccessfully, determine that the node is not the transaction recipient of the target off-chain transaction data.

[0089] The description of S210 - S220 refers to the description of S110 - S140 above, and will not be repeated here.

[0090] S230. If the node is the transaction recipient of the target off-chain transaction data, obtain the encryption key obtained by decrypting the encrypted encryption key; decrypt the encrypted business data according to the encryption key to obtain decrypted transaction data; generate an off-chain transaction block according to the decrypted transaction data.

[0091] In this embodiment, the target off-chain transaction data also includes encrypted business data, and the encrypted business data is encrypted by an encryption key.

[0092] The terminal can negotiate with the transaction recipient, and after negotiation, determine an encryption key for encrypting the data in the communication process (the encryption key can be a random number determined based on a symmetric encryption algorithm), and then the terminal and the transaction receiver respectively store the determined encryption key. Afterwards, the terminal can encrypt the data generated by the target transaction with the encryption key to obtain encrypted business data, and encrypt the encryption key with the above public key, and obtain the target transaction data based on the encrypted encryption key and encrypted business data. The transaction data stored in the local transaction pool is obtained in the same way as the target transaction data. Therefore, the target off-chain transaction data obtained by the local transaction pool also includes the encrypted encryption key and encrypted business data.

[0093] Determining that the node is the transaction recipient of the target off-chain transaction data means that the encrypted encryption key can be decrypted by the private key in the node, and the encrypted business data in the target off-chain transaction data can be decrypted by the encryption key. At this time, the decrypted encryption key can be obtained, and then the encrypted business data can be decrypted by the encryption key, and then the off-chain transaction block can be generated according to the decrypted transaction data.

[0094] Key encryption key, also known as key exchange algorithm, refers to the algorithm used to securely exchange keys between communicating parties. The communicating parties use asymmetric encryption algorithms to encrypt and decrypt data, but the performance of asymmetric encryption algorithms is slow, so they cannot be directly used to encrypt large amounts of data during communication. Therefore, the communicating parties need to use a secure way to exchange the keys used in symmetric encryption algorithms. This process is called key encryption key.

[0095] In the key encryption key algorithm, the two communicating parties first negotiate a symmetric key for encrypting the data during the communication process. This key can be generated using a random number generator. Then, the two communicating parties use the other party's public key to encrypt the symmetric key. The encrypted symmetric key can only be decrypted using the corresponding private key. In this way, the two communicating parties have safely exchanged symmetric keys and can use symmetric encryption algorithms to encrypt data during the communication process.

[0096] KEK stands for Key Encryption Key and DEK stands for Data Encryption Key.

[0097] KEK is usually a longer, more secure key used to encrypt and protect DEK. DEK is a symmetric key used to encrypt and decrypt actual data. In encrypted communications, DEK is usually encrypted with KEK, and then DEK is used to encrypt and decrypt actual data in the communication. This method can improve the security of communication because DEK can be changed frequently while KEK can remain unchanged. If DEK is exposed or leaked, the communicating parties only need to change DEK without changing KEK, which can reduce the number of times the key is renegotiated between the communicating parties.

[0098] Symmetric encryption is a type of encryption, also known as key encryption, that is, in this application, the encryption and decryption of encrypted business data is achieved through a symmetric encryption algorithm. In symmetric encryption, the sender and the receiver use the same key to encrypt and decrypt data.

[0099] The advantage of symmetric encryption is that it is fast and suitable for encryption and decryption of large amounts of data. But its disadvantage is that the key needs to be shared between the sender and the receiver, so the security of the key needs to be ensured. If the key is leaked, the confidentiality of the encrypted data will be destroyed.

[0100] Common symmetric encryption algorithms include DES, 3DES, AES, etc. Among them, AES is one of the most commonly used symmetric encryption algorithms. It has the advantages of high strength, high speed and versatility, and is widely used in protecting data security.

[0101] Asymmetric encryption is a type of encrypted communication, also known as public key encryption, which means that the encryption of the encryption key in this application is implemented through an asymmetric encryption algorithm. In this method, different keys are used for encryption and decryption, called public key and private key respectively. The sender encrypts the data using the receiver's public key, and the receiver decrypts the data using his own private key.

[0102] The advantage of asymmetric encryption is that it can ensure the security of the key, because the private key is only known to the receiver and the sender cannot obtain the private key. This method is suitable for encryption and decryption of small amounts of data, such as passwords, digital signatures, and secure identity authentication.

[0103] At the same time, the disadvantages of asymmetric encryption are high computational complexity, slow speed, and unsuitable for encryption and decryption of large amounts of data. Therefore, in practical applications, asymmetric encryption is usually used in combination with symmetric encryption to balance security and efficiency.

[0104] S240: If the node is not the transaction recipient of the target off-chain transaction data, broadcast the target off-chain transaction data to other nodes in the blockchain system.

[0105] When the node is not the transaction receiver of the target off-chain transaction data, it is determined that the node cannot process the target off-chain transaction data, so the target off-chain transaction data can be broadcast to other nodes in the blockchain system. Among them, the structure of other nodes is the same as that of the node, and can include blockchain, consensus node instance, stand-alone node instance, local ledger, local transaction pool, chain transaction pool, executor and contract virtual machine, etc.

[0106] After receiving the target off-chain transaction data, other nodes can determine whether the target off-chain transaction data is an off-chain transaction (because other nodes have not determined the transaction type, they do not know that the target off-chain transaction data is an off-chain transaction). If it is determined that the target off-chain transaction data is an off-chain transaction data, the target off-chain transaction data is stored in the local transaction pool, and then the target off-chain transaction data is taken out from the local transaction pool, and then other nodes themselves are further determined to determine whether they are the transaction recipients of the target off-chain transaction data.

[0107] For other nodes that are not the transaction recipients of the target off-chain transaction data, they will no longer forward the target off-chain transaction data and will stop the transaction. For other nodes that are the transaction recipients of the target off-chain transaction data, they will decrypt the encrypted encryption key using their own stored private key to obtain the encryption key, and use the encryption key to decrypt the encrypted business data in the target off-chain transaction data to obtain the decrypted business data, and then generate an off-chain transaction block based on the decrypted business data. After that, other nodes will call their own stand-alone node instances to execute the off-chain transaction blocks to obtain the off-chain transaction results. Finally, the off-chain transaction results and off-chain transaction blocks will be stored in their own local ledgers.

[0108] Among them, other nodes can call their own stand-alone node instances to create transaction processes through executors; through the created transaction process, call the contract virtual machine to execute the off-chain transaction block to obtain the off-chain transaction results.

[0109] As an implementation method, the node also includes off-chain transaction records. If the node is not the transaction recipient of the target off-chain transaction data, the target transaction data can also be stored in the node's off-chain transaction records. The off-chain transaction record is used to store off-chain transaction data whose transaction recipient is not the node itself, so as to facilitate querying the off-chain transaction data received by the node through the off-chain transaction record.

[0110] It is understandable that for other nodes, if the other nodes are not the transaction recipients of the target off-chain transaction data, the target transaction data will also be stored in the off-chain transaction records of the other nodes themselves.

[0111] The node broadcasts the target off-chain transaction data to other nodes through P2P (peer-to-peer) broadcast or P2P multicast. P2P broadcast refers to the broadcast method in a peer-to-peer network, that is, a node sends a data packet to all other nodes. This broadcast method is different from the traditional broadcast method based on the broadcast address. It is achieved by directly sending data packets to other nodes. P2P broadcast is usually used in application scenarios such as P2P streaming media and P2P file sharing.

[0112] P2P multicast is a point-to-point network transmission method that allows multiple peer nodes to receive and send the same data stream at the same time, thereby improving the efficiency and reliability of network transmission. Compared with traditional single-point transmission methods, P2P multicast can reduce the burden on servers, reduce network congestion and latency, and improve the reliability of data transmission.

[0113] In this embodiment, the transaction data is encrypted business data, and the encryption key used to encrypt the data is encrypted through the public key, which improves the security and integrity of the encryption key and transaction data, thereby ensuring the safe and stable execution of the transaction process.

[0114] See also Figure 6 , Figure 6 A flowchart of a transaction processing method proposed in another embodiment of the present application is shown. The method can be applied to a node in a blockchain system. The method includes:

[0115] S310. In response to receiving the target transaction data sent by the terminal, the target transaction data is stored in the chain transaction pool; if the transaction type of the target transaction data is an off-chain transaction, the target transaction data is stored in the local transaction pool; and the target off-chain transaction data to be processed is obtained from the local transaction pool.

[0116] S320: If it is determined that the transaction recipient of the target off-chain transaction data is a node based on the unencrypted transaction recipient information, an off-chain transaction block is generated based on the target off-chain transaction data.

[0117] The description of S310 - S320 refers to the description of S110 - S140 above, which will not be repeated here.

[0118] S330: If it is determined based on the unencrypted transaction recipient information that the transaction recipient of the target off-chain transaction data is not a node, the target off-chain transaction data is sent to the target node where the transaction recipient indicated by the unencrypted transaction recipient information is located.

[0119] According to the unencrypted transaction recipient information, a target node serving as a transaction recipient of target off-chain transaction data can be determined in the blockchain system, and the target off-chain transaction data can be sent to the target node.

[0120] After the target node receives the target off-chain transaction data, it can determine whether the target off-chain transaction data is an off-chain transaction (because the target node has not determined the transaction type, it does not know that the target off-chain transaction data is an off-chain transaction). If it is determined that the target off-chain transaction data is an off-chain transaction data, the target off-chain transaction data is stored in the local transaction pool, and then the target off-chain transaction data is taken out from the local transaction pool, and then it is determined whether the target node itself is the transaction recipient of the target off-chain transaction data.

[0121] Determine that the target node is the transaction recipient of the target off-chain transaction data. The target node can decrypt the encrypted encryption key through its own stored private key to obtain the encryption key, and decrypt the encrypted business data in the target off-chain transaction data through the encryption key to obtain the decrypted business data, and then generate an off-chain transaction block based on the decrypted business data. After that, the target node calls its own stand-alone node instance to execute the obtained off-chain transaction block to obtain the off-chain transaction result; finally, the target node stores the off-chain transaction result and the off-chain transaction block in its own local account book.

[0122] Among them, the target node can be a stand-alone node instance that calls its own to create a transaction process through the executor; through the created transaction process, the contract virtual machine is called to execute the off-chain transaction block to obtain the off-chain transaction result.

[0123] The transmission of target off-chain transaction data from a node to a target node can be achieved through peer-to-peer communication or unicast. Peer-to-peer communication is a communication mode in which two nodes communicate directly, sending and receiving messages to each other without going through an intermediate node or agent. In peer-to-peer communication, the sender sends a message to the receiver, and the receiver directly receives and processes the message.

[0124] Peer-to-peer communication is usually associated with a client-server architecture, where a client node sends a request to a server node, and the server node responds to the request and sends the response back to the client node. This communication pattern is widely used in many applications, such as a web browser sending HTTP requests to a web server, an email client sending SMTP requests to a mail server, etc.

[0125] Peer-to-peer communication is usually a real-time communication mode because two nodes can exchange messages directly without the help of intermediate nodes or agents. This communication mode can provide low latency and high bandwidth, so it is widely used in many real-time applications, such as real-time video and audio communication, online games, and financial trading systems.

[0126] Unicast refers to a one-to-one transmission method in network communication, that is, sending data packets from one sender to one receiver. This method has only one destination, which is different from broadcast and multicast.

[0127] In this embodiment, after the node is not the transaction recipient of the target off-chain transaction data, the target off-chain transaction data can be sent directly to the target node as the transaction recipient through the transaction recipient information in the target off-chain transaction data, and the target node performs transaction processing based on the target off-chain transaction data. This eliminates the need for the node to broadcast the target off-chain transaction data to other nodes, thereby achieving point-to-point transmission of the target off-chain transaction data and improving the transmission efficiency and accuracy of the target off-chain transaction data.

[0128] At the same time, there is no need to build additional dedicated line connections between nodes in the blockchain system. The point-to-point communication channel of the blockchain network can be directly reused to reduce network complexity and operation and maintenance complexity; inter-process communication is eliminated to reduce the technical complexity of maintaining data consistency.

[0129] See also Figure 7 , Figure 7 A flowchart of a transaction processing method proposed in another embodiment of the present application is shown. The method can be applied to a node in a blockchain system. The method includes:

[0130] S410. In response to receiving the target transaction data sent by the terminal and the target digital signature corresponding to the target transaction data, the target digital signature corresponding to the target transaction data is verified; if the target digital signature verification is successful, the target transaction data is stored in the chain transaction pool.

[0131] The terminal can obtain the corresponding business data according to the target transaction, digitally sign the business data to obtain the target digital signature, encrypt the business data with the encryption key to obtain encrypted business data, and then encrypt the encryption key with the public key to obtain the encrypted encryption key, and finally summarize the target digital signature, encrypted business data and the encrypted encryption key to obtain the target transaction data.

[0132] Digital signature is a technology used to ensure the authenticity, integrity and non-repudiation of digital documents (such as e-mails, electronic contracts, software, etc.). Digital signature technology is widely used in e-commerce, digital certificates, digital copyright and other fields.

[0133] In this embodiment, the process of determining the target digital signature includes the following steps:

[0134] Create message digest: Use the hash function to generate a message digest for the original target transaction data to obtain the target digest, which is used to ensure the integrity of the data.

[0135] Private key encryption: The terminal uses its own digest private key to encrypt the target digest and generate a digital signature as the target digital signature.

[0136] After the node obtains the target digital signature, it can verify the target digital signature. The processing may include:

[0137] Public key verification: The node uses the terminal's summary public key to decrypt the target digital signature and obtains the decrypted summary.

[0138] Verification digest: The node uses the same hash function to generate a message digest for the target transaction data as the verification digest, and compares the verification digest with the decrypted digest to verify the integrity of the data.

[0139] If the verification summary is the same as the decrypted summary, it is determined that the target digital signature verification is successful, indicating that the digital signature verification has passed; if the verification summary is different from the decrypted summary, it is determined that the target digital signature verification has failed, indicating that the digital signature verification has not passed.

[0140] If the digital signature verification is successful, the node can trust the authenticity and integrity of the data, and the terminal cannot deny the source and content of the data.

[0141] The terminal can create a summary private key and a summary public key, and send the summary private key and the hash function (or the name of the hash function) used to determine the target digital signature to the node. After receiving the target digital signature, the node verifies the target digital signature through the hash function and the summary public key.

[0142] S420. Obtain the target chain transaction data from the chain transaction pool; generate a chain transaction block according to the target chain transaction data.

[0143] The target on-chain transaction data at least includes the target transaction data. After determining that the transaction type of the target transaction data is an on-chain transaction, the target on-chain transaction data at least including the target transaction data can be obtained from the chain transaction pool, and an on-chain transaction block can be generated according to the target on-chain transaction data.

[0144] Among them, the on-chain transaction block may include an on-chain transaction block header and an on-chain transaction block body. The on-chain transaction block header may include a version (which may be a blockchain version number, etc.), a parent block hash value, a Mikkel root, a timestamp (the time when the on-chain transaction block was created), a difficulty target, and a temporary counter (a counter used for the proof-of-work algorithm), etc. The on-chain transaction block body may include target on-chain transaction data and a hash value of the target on-chain transaction data, etc.

[0145] In this embodiment, the node can call the consensus node instance to verify the transaction data on the target chain (verify whether the transaction data on the target chain is legal and whether the addresses of the two parties to the transaction on the target chain are valid, etc.). If the transaction data on the target chain is verified, an on-chain transaction block is generated based on the transaction data on the target chain.

[0146] S430, calling the consensus node instance to determine the transaction result block according to the on-chain transaction block, and broadcasting the on-chain transaction block to other nodes in the blockchain system.

[0147] The node can execute the on-chain transaction block through the consensus node instance, obtain the on-chain transaction result, and determine the transaction result block according to the on-chain transaction result (the structure of the transaction result block is similar to the structure of the on-chain transaction block, which will not be repeated). It can be that the consensus node instance executes the transaction according to the target on-chain transaction data in the on-chain transaction block body included in the on-chain transaction block, obtains the on-chain transaction result, and determines the transaction result block according to the on-chain transaction result.

[0148] As an implementation method, the node may also include a contract virtual machine, which may call the consensus node instance to execute the on-chain transaction block through the contract virtual machine to obtain a transaction result block.

[0149] As another implementation, the node may also include a contract virtual machine and an executor; the node may call the consensus node example executor to create a transaction process; and the transaction process may call the contract virtual machine to execute the on-chain transaction block to obtain a transaction result block.

[0150] Nodes can broadcast on-chain transaction blocks to other nodes in the blockchain system. After receiving the on-chain transaction blocks, other nodes verify the target on-chain transaction data in the on-chain transaction blocks (verify whether the target on-chain transaction data is legal and whether the addresses of the two parties to the target on-chain transaction are valid, etc.). If the target on-chain transaction data is verified, other nodes call their own consensus node instances to execute the on-chain transaction blocks and obtain the transaction result blocks.

[0151] S440, calling the consensus node instance to reach a consensus on the transaction result block in the blockchain system, and writing the transaction result block into the node's blockchain if the consensus is passed.

[0152] The node and other nodes determine their own transaction result blocks based on the on-chain transaction blocks. The nodes can call the consensus node instance and reach consensus on the transaction result blocks in the blockchain system through consensus algorithms such as PoW (Proof of Work), PoS (Proof of Stake), DPoS (Delegated Proof of Stake), PBFT (Practical Byzantine Fault Tolerance), and POOL (Verification Pool).

[0153] If the consensus is passed and the on-chain transaction is confirmed to be executed successfully, the node will directly write the transaction result block into the node's blockchain. At the same time, other nodes can also directly write their own transaction result blocks into their own blockchains when they confirm that the consensus is passed.

[0154] In this embodiment, the node can also execute on-chain transactions. The node can not only realize on-chain transactions but also off-chain transactions. There is no need to set up an additional off-chain transaction system, which saves the cost of deploying the off-chain transaction system.

[0155] At the same time, this embodiment also expands the use of blockchain, so that blockchain can handle both on-chain and off-chain businesses. On-chain and off-chain businesses uniformly use the original blockchain interface, without increasing the complexity of external services; using contract virtual machines to handle off-chain businesses, hot deployment is easily achieved, business launch is smoother, and operation and maintenance are easier; one system implements two businesses, simplifies the system architecture, reduces technical complexity, and lowers the technical threshold.

[0156] In addition, the on-chain and off-chain business systems are unified, a single programming language is used, the technology stack is reduced, and maintainability is improved; the business system is implemented using smart contracts, hot deployment is easily achieved, new businesses are launched in real time, operation and maintenance are more flexible, and the business experience is smoother.

[0157] In order to explain the technical solution of the present application more clearly, the transaction processing method of the present application is explained below in conjunction with an exemplary scenario. In this scenario, it is assumed that the blockchain system includes at least three nodes, numbered as node 1, node 2, and node 3, each of which is a transaction node. The structure of the node is as follows: Figure 8 As shown in the figure, the nodes include: chain transaction pool, executor, consensus node instance, blockchain, local transaction pool, stand-alone node instance and local ledger. Among them, the off-chain transaction record is part of the local ledger.

[0158] In this scenario, the user sends two transaction data to node 1 through the terminal: target transaction data 1 and target transaction data 2. Both target transaction data 1 and target transaction data 2 include an encrypted encryption key and encrypted business data.

[0159] For target transaction data 1, the transaction processing flow is as follows: Fig. 9 As shown, including:

[0160] Node 1 responds to the target transaction data 1 and the target digital signature of the target transaction data 1 sent by the terminal, verifies the target digital signature of the target transaction data 1, and after the verification is passed, stores the target transaction data 1 in the chain transaction pool of node 1.

[0161] Afterwards, the transaction type of the target transaction data 1 is determined to be an off-chain transaction, and the target transaction data 1 is stored in the local transaction pool of node 1. Node 1 obtains the target transaction data 1 from the local transaction pool as the target off-chain transaction data, and decrypts the encrypted encryption key through the private key pair in node 1. After the decryption fails, it is determined that node 1 is not the transaction recipient of the target transaction data 1, and the off-chain transaction record from the target transaction data 1 to node 1 is stored. At the same time, node 1 broadcasts the target transaction data 1 to nodes 2 and 3.

[0162] Node 2 responds to the target transaction data 1 sent by node 1 and stores the target transaction data 1 in the chain transaction pool of node 2. After that, node 2 determines that the transaction type of the target transaction data 1 is an off-chain transaction, stores the target transaction data 1 in the local transaction pool of node 2, obtains the target transaction data 1 from the local transaction pool as the target off-chain transaction data, and decrypts the encrypted encryption key through the private key pair in node 2. After the decryption fails, it is determined that node 2 is not the transaction recipient of the target transaction data 1, and stores the off-chain transaction record from the target transaction data 1 to node 2.

[0163] Node 3 responds to the target transaction data 1 sent by node 1 and stores the target transaction data 1 in the chain transaction pool of node 3. After that, node 3 determines that the transaction type of the target transaction data 1 is an off-chain transaction, stores the target transaction data 1 in the local transaction pool of node 3, obtains the target transaction data 1 from the local transaction pool as the target off-chain transaction data, and decrypts the encrypted encryption key through the private key pair in node 3. After the decryption is successful, it is determined that node 3 is the transaction recipient of the target transaction data 1. Node 3 decrypts the encrypted business data in the target transaction data 1 through the decrypted encryption key to obtain the decrypted transaction data; node 3 generates an off-chain transaction block according to the decrypted transaction data, node 3 calls its own stand-alone node instance to execute the off-chain transaction block, and obtains the off-chain transaction result; the off-chain transaction result and the off-chain transaction block are stored in the local account book of node 3.

[0164] For target transaction data 2, the transaction processing flow is as follows: Fig.10 As shown, including:

[0165] Node 1 responds to the target transaction data 2 and the target digital signature of the target transaction data 2 sent by the terminal, verifies the target digital signature of the target transaction data 2, and after the verification is passed, stores the target transaction data 2 in the chain transaction pool of node 1.

[0166] Afterwards, it is determined that the transaction type of the target transaction data 2 is an on-chain transaction. Node 1 obtains the target transaction data 2 from the chain transaction pool as the target on-chain transaction data. Node 1 generates an on-chain transaction block according to the target on-chain transaction data, and executes the on-chain transaction block through the consensus node instance to determine the transaction result block. At the same time, node 1 broadcasts the on-chain transaction block to nodes 2 and 3 through the consensus node instance, so that the consensus node instances in nodes 1, 2, and 3 can reach a consensus on the transaction result block in the blockchain system. When the consensus is passed, nodes 1, 2, and 3 store the transaction result blocks generated by each of them in their respective blockchains.

[0167] In this scenario, on-chain and off-chain businesses are completed in the same blockchain system and in the same process, without the need to implement two systems, which simplifies the system architecture. Unify on-chain and off-chain business systems, use a single programming language, reduce the technology stack, and improve maintainability; use smart contracts to implement business systems, easily implement hot deployment, and launch new businesses in real time, making operation and maintenance more flexible and the business experience smoother.

[0168] See also Fig.11 , Fig.11 A block diagram of a transaction processing device proposed in one embodiment of the present application is shown, and the device 1100 includes:

[0169] A response module 1110, configured to store the target transaction data in a chain transaction pool in response to receiving the target transaction data sent by the terminal;

[0170] The data storage module 1120 is used to store the target transaction data in a local transaction pool if the transaction type of the target transaction data is an off-chain transaction;

[0171] The acquisition module 1130 is used to acquire the target off-chain transaction data to be processed from the local transaction pool;

[0172] The block generation module 1140 is used to generate an off-chain transaction block according to the target off-chain transaction data if the node is a transaction recipient of the target off-chain transaction data;

[0173] An execution module 1150 is used to call a stand-alone node instance to execute an off-chain transaction block and obtain an off-chain transaction result;

[0174] The result storage module 1160 is used to store the off-chain transaction results and off-chain transaction blocks in the local account book.

[0175] Optionally, the node also includes a consensus node instance and a blockchain; the device also includes an on-chain transaction module, which is used to obtain target on-chain transaction data from a chain transaction pool; generate an on-chain transaction block according to the target on-chain transaction data; call the consensus node instance to determine the transaction result block according to the on-chain transaction block, and broadcast the on-chain transaction block to other nodes in the blockchain system; call the consensus node instance to reach a consensus on the transaction result block in the blockchain system, and write the transaction result block into the node's blockchain if the consensus is passed.

[0176] Optionally, the node includes a contract virtual machine; the execution module 1150 is also used to call a stand-alone node instance to execute an off-chain transaction block through the contract virtual machine to obtain an off-chain transaction result.

[0177] Optionally, the node also includes an executor; the execution module 1150 is also used to call the stand-alone node instance to create a transaction process through the executor; call the contract virtual machine through the transaction process to execute the off-chain transaction block to obtain the off-chain transaction result.

[0178] Optionally, the device also includes a broadcast module, which is used to broadcast the target off-chain transaction data to other nodes in the blockchain system if the node is not a transaction recipient of the target off-chain transaction data.

[0179] Optionally, the target off-chain transaction data includes an encrypted encryption key, which is encrypted by the public key of the terminal; the block generation module 1140 is also used to decrypt the encrypted encryption key by the private key of the node; if the encrypted encryption key is decrypted successfully, the node is determined to be the transaction recipient of the target off-chain transaction data; if the encrypted encryption key fails to be decrypted, it is determined that the node is not the transaction recipient of the target off-chain transaction data.

[0180] Optionally, the target off-chain transaction data also includes encrypted business data, which is encrypted by an encryption key; the block generation module 1140 is also used to obtain the encryption key obtained by decrypting the encrypted encryption key if the node is the transaction recipient of the target off-chain transaction data; decrypt the encrypted business data according to the encryption key to obtain decrypted transaction data; and generate an off-chain transaction block according to the decrypted transaction data.

[0181] Optionally, the target transaction data also includes unencrypted transaction recipient information; the block generation module 1140 is also used to generate an off-chain transaction block according to the target off-chain transaction data if it is determined that the transaction recipient of the target off-chain transaction data is a node based on the unencrypted transaction recipient information.

[0182] Optionally, the broadcast module is also used to send the target off-chain transaction data to the target node where the transaction recipient indicated by the unencrypted transaction recipient information is located if it is determined based on the unencrypted transaction recipient information that the transaction recipient of the target off-chain transaction data is not a node.

[0183] Optionally, the response module 1110 is further used to verify the target digital signature corresponding to the target transaction data in response to receiving the target transaction data sent by the terminal; if the target digital signature verification is successful, the target transaction data is stored in the chain transaction pool.

[0184] Optionally, the data storage module 1120 is further configured to obtain a transaction type field from the target transaction data; and determine the transaction type of the target transaction data according to the transaction type field.

[0185] It should be noted that the device embodiment in the present application corresponds to the aforementioned method embodiment. The specific principles in the device embodiment can be found in the contents of the aforementioned method embodiment and will not be repeated here.

[0186] Fig.12 The structure block diagram of an electronic device for executing the transaction processing method according to an embodiment of the present application is shown. The electronic device may be a node in a blockchain, etc. It should be noted that Fig.12 The computer system 1200 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0187] like Fig.12 As shown, the computer system 1200 includes a central processing unit (CPU) 1201, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 1202 or the program loaded from the storage part 1208 to the random access memory (RAM) 1203, such as executing the method in the above embodiment. In RAM 1203, various programs and data required for system operation are also stored. CPU 1201, ROM 1202 and RAM 1203 are connected to each other through bus 1204. Input / output (I / O) interface 1205 is also connected to bus 1204.

[0188] The following components are connected to the I / O interface 1205: an input section 1206 including a keyboard, a mouse, etc.; an output section 1207 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1208 including a hard disk, etc.; and a communication section 1209 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 1209 performs communication processing via a network such as the Internet. A drive 1210 is also connected to the I / O interface 1205 as needed. A removable medium 1211, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1210 as needed so that a computer program read therefrom is installed into the storage section 1208 as needed.

[0189] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 1209, and / or installed from a removable medium 1211. When the computer program is executed by a central processing unit (CPU) 1201, various functions defined in the system of the present application are executed.

[0190] It should be noted that the computer-readable medium shown in the embodiment of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, - but not limited to - an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by an instruction execution system, device or device or used in combination with it. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0191] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0192] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.

[0193] As another aspect, the present application further provides a computer-readable storage medium, which may be included in the electronic device described in the above embodiments; or may exist independently without being assembled into the electronic device. The above computer-readable storage medium carries computer-readable instructions, and when the computer-readable storage instructions are executed by a processor, the method in any of the above embodiments is implemented.

[0194] According to one aspect of the embodiments of the present application, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device executes the method in any of the above embodiments.

[0195] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.

[0196] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the implementation method of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable an electronic device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the implementation method of the present application.

[0197] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the embodiments disclosed herein. The present application is intended to cover any variations, uses or adaptations of the present application, which follow the general principles of the present application and include common knowledge or customary techniques in the art that are not disclosed in the present application. It should be understood that the present application is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

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

Claims

1. A transaction processing method, characterized in that: A node used in a blockchain system, wherein the node includes a stand-alone node instance, a local ledger, a local transaction pool, and a chain transaction pool; the local transaction pool is used to store off-chain transaction data; The chain transaction pool is used to store on-chain transaction data; the method includes: In response to receiving the target transaction data sent by the terminal, storing the target transaction data in the chain transaction pool; If the transaction type of the target transaction data is an off-chain transaction, storing the target transaction data in the local transaction pool; Obtaining target off-chain transaction data to be processed from the local transaction pool; If the node is the transaction recipient of the target off-chain transaction data, generate an off-chain transaction block according to the target off-chain transaction data; Calling the stand-alone node instance to execute the off-chain transaction block to obtain the off-chain transaction result; The off-chain transaction result and the off-chain transaction block are stored in the local ledger.

2. The method according to claim 1, characterized in that The node also includes a consensus node instance and a blockchain; in response to receiving the target transaction data sent by the terminal, after storing the target transaction data in the chain transaction pool, the method also includes: Obtain transaction data on the target chain from the chain transaction pool; Generate an on-chain transaction block according to the target on-chain transaction data; Calling the consensus node instance to determine a transaction result block according to the on-chain transaction block, and broadcasting the on-chain transaction block to other nodes in the blockchain system; The consensus node instance is called to reach a consensus on the transaction result block in the blockchain system, and if the consensus is passed, the transaction result block is written into the blockchain of the node.

3. The method according to claim 1, characterized in that The node includes a contract virtual machine; the calling of the stand-alone node instance to execute the off-chain transaction block to obtain the off-chain transaction result includes: The stand-alone node instance is called to execute the off-chain transaction block through the contract virtual machine to obtain the off-chain transaction result.

4. The method according to claim 3, characterized in that The node also includes an executor; the calling of the stand-alone node instance to execute the off-chain transaction block through the contract virtual machine to obtain the off-chain transaction result includes: Calling the stand-alone node instance to create a transaction process through the executor; The contract virtual machine is called by the transaction process to execute the off-chain transaction block to obtain the off-chain transaction result.

5. The method according to claim 1, characterized in that After obtaining the target off-chain transaction data to be processed from the local transaction pool, the method further includes: If the node is not the transaction recipient of the target off-chain transaction data, broadcast the target off-chain transaction data to other nodes in the blockchain system.

6. The method according to claim 1, characterized in that The target off-chain transaction data includes an encrypted encryption key, and the encrypted encryption key is encrypted by the public key of the terminal; If the node is the transaction recipient of the target off-chain transaction data, before generating an off-chain transaction block according to the target off-chain transaction data, the method further includes: Decrypting the encrypted encryption key using the private key of the node; If the encrypted encryption key is successfully decrypted, the node is determined to be the transaction recipient of the target off-chain transaction data; If the encrypted encryption key fails to be decrypted, it is determined that the node is not the transaction recipient of the target off-chain transaction data.

7. The method according to claim 6, characterized in that The target off-chain transaction data also includes encrypted business data, and the encrypted business data is encrypted by the encryption key; If the node is the transaction recipient of the target off-chain transaction data, generating an off-chain transaction block according to the target off-chain transaction data includes: If the node is a transaction recipient of the target off-chain transaction data, obtaining an encryption key obtained by decrypting the encrypted encryption key; Decrypting the encrypted business data according to the encryption key to obtain decrypted transaction data; Generate an off-chain transaction block based on the decrypted transaction data.

8. The method according to claim 1, characterized in that The target transaction data includes unencrypted transaction recipient information; If the node is the transaction recipient of the target off-chain transaction data, generating an off-chain transaction block according to the target off-chain transaction data includes: If it is determined according to the unencrypted transaction recipient information that the transaction recipient of the target off-chain transaction data is the node, an off-chain transaction block is generated according to the target off-chain transaction data.

9. The method according to claim 8, characterized in that The method further comprises: If it is determined based on the unencrypted transaction recipient information that the transaction recipient of the target off-chain transaction data is not the node, the target off-chain transaction data is sent to the target node where the transaction recipient indicated by the unencrypted transaction recipient information is located.

10. The method according to claim 1, characterized in that In response to receiving the target transaction data sent by the terminal, storing the target transaction data in the chain transaction pool includes: In response to receiving the target transaction data sent by the terminal, verifying the target digital signature corresponding to the target transaction data; If the target digital signature verification is successful, the target transaction data is stored in the chain transaction pool.

11. The method according to claim 1, characterized in that: If the transaction type of the target transaction data is an off-chain transaction, before storing the target transaction data in the local transaction pool, the method further includes: Acquire a transaction type field from the target transaction data; The transaction type of the target transaction data is determined according to the transaction type field.

12. A transaction processing device, characterized in that: A node used in a blockchain system, wherein the node includes a stand-alone node instance, a local ledger, a local transaction pool, and a chain transaction pool; the local transaction pool is used to store off-chain transaction data; The chain transaction pool is used to store on-chain transaction data; the device includes: A response module, configured to store the target transaction data in the chain transaction pool in response to receiving the target transaction data sent by the terminal; A data storage module, configured to store the target transaction data in the local transaction pool if the transaction type of the target transaction data is an off-chain transaction; An acquisition module, used to acquire target off-chain transaction data to be processed from the local transaction pool; A block generation module, configured to generate an off-chain transaction block according to the target off-chain transaction data if the node is a transaction recipient of the target off-chain transaction data; An execution module, used to call the stand-alone node instance to execute the off-chain transaction block and obtain the off-chain transaction result; The result storage module is used to store the off-chain transaction result and the off-chain transaction block in the local account book.

13. An electronic device, characterized in that: include: one or more processors; Memory; One or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the method according to any one of claims 1-11.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program codes, which can be called by a processor to execute the method according to any one of claims 1 to 11.

15. A computer program product or a computer program, characterized in that The computer program product or computer program includes computer instructions, which are stored in a computer-readable storage medium; a processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device executes the method as described in any one of claims 1-11.