Transaction execution method in blockchain, node in blockchain, and system

By using the Trusted Execution Environment (TEE) in the blockchain node to execute transactions and generate signatures, the problem of low blockchain transaction execution efficiency is solved, and efficient processing of transactions and optimal utilization of resources are achieved.

WO2024221907A1PCT designated stage expired Publication Date: 2024-10-31ANT BLOCKCHAIN TECHNOLOGY (SHANGHAI) CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2023/135009
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-04-28
Filing Date
2023-11-29
Publication Date
2024-10-31

Smart Images

  • Figure CN2023135009_31102024_PF_FP_ABST
    Figure CN2023135009_31102024_PF_FP_ABST
Patent Text Reader

Abstract

A transaction execution method in a blockchain, a node in a blockchain, and a system. The blockchain comprises a first node and a second node, wherein the first node comprises a TEE. The method comprises: a first node executing a first transaction in a TEE to obtain a first execution read-write set of the first transaction, and signing the first execution read-write set by using a private key in the TEE, so as to obtain a first signature, wherein the first execution read-write set comprises a first execution read set and a first execution write set; sending the first execution read-write set and the first signature to a second node; and the second node verifying the first signature by using a public key corresponding to the private key, and after the verification of the first signature is passed, verifying the first execution read set, and when the verification of the first execution read set is passed, storing the first execution write set as an execution write set of the first transaction.
Need to check novelty before this filing date? Find Prior Art

Description

Transaction execution method, node and system in blockchain

[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office of China on April 28, 2023, with application number 202310486095.1 and application name “Transaction Execution Method, Node and System in Blockchain”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The embodiments of this specification belong to the field of blockchain technology, and more particularly to a transaction execution method, node, and system in a blockchain. Background Art

[0003] Blockchain is a novel application model for computer technologies, including distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. In a blockchain system, data blocks are linked sequentially in chronological order to form a chain-like data structure, cryptographically guaranteeing an unalterable and unforgeable distributed ledger. Due to its decentralized, tamper-proof, and autonomous nature, blockchain is gaining increasing attention and application.

[0004] A Trusted Execution Environment (TEE) can be introduced into the blockchain, which can ensure the security, confidentiality and integrity of the code and data placed in it.

[0005] Summary of the Invention

[0006] The purpose of the present invention is to provide a transaction execution solution in a blockchain to improve the transaction execution efficiency in the blockchain.

[0007] In a first aspect, the present specification provides a transaction execution method in a blockchain, wherein the blockchain includes a first node and a second node, the first node includes a TEE, and the method includes:

[0008] The first node executes a first transaction in the TEE to obtain a first execution read-write set of the first transaction, signs the first execution read-write set using a private key stored in the TEE to obtain a first signature, where the first execution read-write set includes a first execution read set and a first execution write set; and sends the first execution read-write set and the first signature to the second node.

[0009] The second node verifies the first signature using the public key corresponding to the private key, and after the verification of the first signature is passed, verifies the first execution read set. If the verification is passed, stores the first execution write set as the execution write set of the first transaction.

[0010] A second aspect of this specification provides a transaction execution method in a blockchain, wherein the blockchain includes a first node and a second node, the first node includes a TEE, and the method is executed by the first node, including:

[0011] Executing a first transaction in the TEE to obtain a first execution read-write set of the first transaction;

[0012] Signing the first execution read-write set using the private key of the TEE to obtain a first signature;

[0013] The first execution read-write set and the first signature are sent to the second node.

[0014] A third aspect of this specification provides a transaction execution method in a blockchain, wherein the blockchain includes a first node and a second node, the first node includes a TEE, and the method is executed by the second node, including:

[0015] receiving, from the first node, a first execution read-write set of a first transaction and a first signature of the first execution read-write set generated by the TEE using a private key stored in the TEE, where the first execution read-write set includes a first execution read set and a first execution write set;

[0016] Verifying the first signature using a public key corresponding to the private key;

[0017] After the verification of the first signature is passed, verifying the first execution read set;

[0018] If verification of the first execution read set passes, the first execution write set is stored as the execution write set of the first transaction.

[0019] A fourth aspect of this specification provides a blockchain system, including a first node and a second node, wherein the first node includes a TEE,

[0020] The first node is configured to: execute a first transaction in the TEE to obtain a first execution read-write set of the first transaction; sign the first execution read-write set using a private key stored in the TEE to obtain a first signature, where the first execution read-write set includes a first execution read set and a first execution write set; and send the first execution read-write set and the first signature to the second node;

[0021] The second node is used to: verify the first signature using the public key corresponding to the private key, and after the verification of the first signature is passed, verify the first execution read set; if the verification is passed, store the first execution write set as the execution write set of the first transaction.

[0022] A fifth aspect of this specification provides a first node in a blockchain, wherein the blockchain includes a first node and a second node, the first node includes a TEE, and the first node includes:

[0023] an execution unit, configured to execute a first transaction in the TEE to obtain a first execution read-write set of the first transaction, where the first execution read-write set includes a first execution read set and a first execution write set;

[0024] A signing unit, configured to sign the first execution read-write set using the private key of the TEE to obtain a first signature;

[0025] A sending unit is used to send the first execution read-write set and the first signature to the second node.

[0026] A sixth aspect of this specification provides a second node in a blockchain, wherein the blockchain includes a first node and a second node, the first node includes a TEE, and the second node includes:

[0027] a receiving unit, configured to receive, from the first node, a first execution read-write set of a first transaction and a first signature of the first execution read-write set generated by the TEE using a private key stored in the TEE, the first execution read-write set comprising a first execution read set and a first execution write set;

[0028] a verification unit, configured to verify the first signature using a public key corresponding to the private key; and after the verification of the first signature is successful, verify the first execution read set;

[0029] A storage unit is configured to store the first execution write set as the execution write set of the first transaction if verification of the first execution read set is passed.

[0030] A seventh aspect of this specification provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed in a computer, the computer is caused to execute the method described in the second aspect or the third aspect.

[0031] In an eighth aspect, this specification provides a blockchain node, comprising a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method described in the second aspect or the third aspect is implemented.

[0032] In the embodiments of this specification, the TEE node executes the transaction in the TEE, and sends the execution read-write set of the transaction and its signature to the ordinary node, so that the ordinary node can directly accept the write set in the execution read-write set after verifying the execution read set, that is, store the write set as the execution write set of the transaction without executing the transaction, thereby improving the transaction execution efficiency in the blockchain. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] In order to more clearly illustrate the technical solutions of the embodiments of this specification, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0034] FIG1 shows a diagram of a blockchain architecture in one embodiment;

[0035] FIG2 is a schematic diagram of the process of TEE authentication and uploading the TEE public key to the blockchain performed by the Admin in an embodiment of this specification;

[0036] FIG3 is a schematic diagram of the process of executing a transaction in a TEE node according to an embodiment of this specification;

[0037] FIG4 is a flow chart of a method for executing a transaction in an embodiment of this specification;

[0038] FIG5 is a flow chart of a transaction execution method in another embodiment of the present specification;

[0039] FIG6 is an architectural diagram of a first node in a blockchain according to an embodiment of this specification;

[0040] FIG7 is an architectural diagram of a second node in a blockchain according to an embodiment of this specification. DETAILED DESCRIPTION

[0041] To help those skilled in the art better understand the technical solutions in this specification, the following will provide a clear and complete description of the technical solutions in the embodiments of this specification, in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of them. All other embodiments derived by those skilled in the art based on the embodiments in this specification without creative effort shall fall within the scope of protection of this specification.

[0042] Figure 1 illustrates a blockchain architecture diagram in one embodiment. In the blockchain architecture diagram shown in Figure 1 , blockchain 100 includes N nodes, with nodes 1 through 8 schematically illustrated in Figure 1 . The lines connecting the nodes schematically represent P2P (peer-to-peer) connections, such as TCP connections, for transmitting data between nodes. These nodes can store the full ledger, i.e., the state of all blocks and all accounts. Each node in the blockchain can generate the same state in the blockchain by executing the same transactions, and each node in the blockchain can store the same state database.

[0043] A transaction in the blockchain field can refer to a task unit executed and recorded in the blockchain. A transaction typically includes a sender field (From), a receiver field (To), and a data field (Data). In the case of a transfer transaction, the From field indicates the address of the account initiating the transaction (i.e., initiating a transfer task to another account), the To field indicates the address of the account receiving the transaction (i.e., receiving the transfer), and the Data field includes the transfer amount.

[0044] Blockchains offer smart contract functionality. Smart contracts on blockchains are contracts that can be triggered and executed by transactions within the blockchain system. Smart contracts can be defined in code. Calling a smart contract on a blockchain involves initiating a transaction to the smart contract address, allowing each node in the blockchain to execute the smart contract code in a distributed manner.

[0045] In a contract deployment scenario, for example, Bob sends a transaction containing information about creating a smart contract (i.e., deploying a contract) to the blockchain shown in Figure 1. The transaction's data field includes the code for the contract to be created (such as bytecode or machine code), and the transaction's to field is empty, indicating that the transaction is for contract deployment. After the nodes reach consensus through a consensus mechanism, they determine the contract address "0x6f8ae93..." Each node adds a contract account corresponding to the smart contract's contract address to the state database, allocates state storage corresponding to the contract account, stores the contract code, and saves the hash value of the contract code in the contract's state storage, thus successfully creating the contract.

[0046] In the contract invocation scenario, for example, Bob sends a transaction to invoke a smart contract to the blockchain shown in Figure 1. The transaction's "from" field is the address of the account of the transaction initiator (Bob), the "to" field is the aforementioned "0x6f8ae93...", the address of the invoked smart contract, and the transaction's "data" field includes the method and parameters for invoking the smart contract. After consensus is reached on the blockchain, each node in the blockchain can execute the transaction, thereby executing the contract and updating the state database based on the contract's execution.

[0047] Blockchains can incorporate a node that includes a Trusted Execution Environment (TEE), hereinafter referred to as a TEE node. A TEE is a secure extension of CPU hardware that is completely isolated from the outside world. Currently, the industry is paying close attention to TEE solutions. Almost all major chip and software alliances have their own TEE solutions, such as the TPM (Trusted Platform Module) in software and SGX (Software Guard Extensions), ARM Trustzone, and AMD PSP (Platform Security Processor) in hardware. A TEE acts as a black box, preventing even the operating system from intruding on the code and data executed within it. These operations can only be performed through predefined interfaces within the code. In terms of efficiency, due to the TEE's black-box nature, operations performed within the TEE are performed on plaintext data, rather than the complex cryptographic operations used in homomorphic encryption, resulting in virtually no loss in computational efficiency. Therefore, TEE technology can largely meet the trusted computing requirements of blockchain scenarios with relatively minimal performance loss.

[0048] SGX (Software Guard Extension) is an example of TEE technology. Blockchain nodes can create enclaves (enclaves) based on SGX technology, which serve as TEEs for executing blockchain transactions. Blockchain nodes utilize new processor instructions in the CPU to allocate a portion of memory, the EPC (Enclave Page Cache), to host the enclave. The memory area corresponding to the EPC is encrypted by the CPU's internal Memory Encryption Engine (MEE). The contents of this memory area (code and data within the enclave) can only be decrypted within the CPU core, and the encryption and decryption keys are generated and stored in the CPU only when the EPC is booted. As can be seen, the enclave's security boundary only includes the enclave itself and the CPU. Neither privileged nor unprivileged software can access the enclave. Even operating system administrators and virtual machine monitors (VMMs, also known as hypervisors) cannot affect the code and data within the enclave, resulting in extremely high reliability.

[0049] After creating a TEE in a blockchain TEE node (e.g., node 1 in Figure 1), the specified program code can be loaded into the TEE. Node 1 is used as an example in the following description of the TEE node. The specified program code may include program code for executing transfer transactions, program code for a virtual machine (EVM) for executing contract transactions, and so on. The management server (Admin) used to manage blockchain nodes can initiate a remote authentication process for the TEE, and the TEE can obtain a public and private key pair for encryption during the remote authentication process. Figure 2 is a schematic diagram of the process of TEE authentication and uploading the TEE public key to the blockchain performed by the Admin in an embodiment of this specification. The process is described in detail below.

[0050] Before SGX-enabled CPUs ship, the manufacturer will have the provisioning key and sealing key burned into the CPU's fuse registers. A fuse register is a one-time programmable register. Once data is burned into it, the fuse blows, rendering the register's contents readable but no longer writable. The SGX manufacturer guarantees that the key burned into the fuse register is randomly generated. Furthermore, the manufacturer promises that all backups of the burned-in key will be destroyed after burning, meaning that even the manufacturer itself will not know the burned-in key. The provisioning key can represent some CPU information, such as the CPU code (e.g., 6th-generation Core, 7th-generation Core, etc.) or model (e.g., desktop, mobile, etc.). For security reasons, encryption and signing operations do not directly use the provisioning key. Instead, an attestation key derived from the provisioning key is used. Therefore, the provisioning key serves a deployment purpose.

[0051] Before the Admin initiates remote authentication of the TEE in Node 1, the CPU in the blockchain node can detect whether an attestation key exists. If not, initialization is initiated. During initialization, an EPID (Enhanced Privacy IDentification) can be generated based on the key generation protocol, through interaction with the TEE server and according to the Provisioning Key generation rules. This EPID can be used as the attestation key, typically used as the private key sk1 in asymmetric encryption keys. The generated EPID can be stored in the TEE for subsequent signing operations. Thus, the TEE server can obtain the public key pk1 corresponding to this EPID through this interaction. Notably, the public key pk1 corresponding to this EPID is not publicly available but is maintained only by the TEE server. This feature makes it suitable for subsequent authentication by the TEE server during remote attestation.

[0052] After the TEE prepares the private key sk1 and public key pk1 for remote authentication, it can obtain the private key sk2 and public key pk2 for asymmetric encryption or signature verification through the following steps:

[0053] Step 1: The Admin challenges the TEE in Node 1 to produce a report proving that the program code included therein is correct. Specifically, the report is used to prove that the EVM code in the TEE is correct.

[0054] Step 2: As shown in Figure 2, after receiving the challenge, the TEE in node 1 calculates hash1 of the local code and generates a report (quote) that includes hash1. The quote is signed using the key sk1 to obtain signature sig1, and the quote and its signature sig1 are sent to the Admin.

[0055] The TEE and Admin in node 1 can also obtain the public key pk2 through the Diffie–Hellman key exchange (DH) algorithm or the Elliptic Curve Diffie–Hellman key exchange (ECDH) algorithm in steps 1 and 2. In this case, the hash value hash2 of the public key pk2 can also be included in the quote;

[0056] Step 3: Since Admin does not have the public key pk1 corresponding to sk1, after receiving the quote and its signature sig1, Admin sends the quote and its signature sig1 to the TEE server as shown in Figure 2;

[0057] Step 4: The TEE server uses the public key pk1 to verify the signature sig1 of quote, as shown in Figure 2, and returns the verification result to the Admin. To prevent the verification result from being intercepted or modified by the middle, the TEE server can use its own private key to sign the verification result to obtain the signature sig2, and send the verification result and its signature sig2 together to the Admin;

[0058] Step 5: After receiving the verification result, if the verification result indicates that sig1 is correct, the Admin verifies hash1 in the quote according to the correct hash value of the EVM code obtained in advance. If they are consistent, the remote proof verification is passed, that is, the Admin confirms that the correct EVM is running in the TEE of node 1. For example, the Admin can download the correct EVM code from the official developer of the EVM and calculate the correct hash value of the EVM code based on the correct EVM code;

[0059] Step 6: Admin generates a private key sk2 corresponding to the public key pk2, symmetrically encrypts the private key sk2 using the public key pk2, and sends the encrypted private key to the TEE of node 1;

[0060] Step 7: After receiving the encrypted private key, the TEE of node 1 can use the public key pk2 to decrypt the encrypted private key to obtain the private key sk2, and store the private key sk2 together with the public key pk2 in the TEE.

[0061] After the Admin sends the private key sk2 to Node 1's TEE, they can send a transaction Tx1 to the blockchain that calls the system contract. This transaction uploads Node 1's node information to the blockchain, thereby adding Node 1 to the blockchain. This node information includes Node 1's TEE public key (i.e., the aforementioned public key pk2). The blockchain is pre-deployed with a system contract that manages nodes within the blockchain, such as adding or removing nodes. The Admin can manage nodes within the blockchain by sending a transaction that calls this system contract. For TEE nodes, in addition to including general node attributes (such as node ID and IP address) in transaction Tx1, it also includes the TEE public key, which is used to upload the TEE public key to the blockchain. This allows other nodes in the blockchain to query the contract status of the system contract and retrieve Node 1's TEE public key, allowing them to verify the TEE's signature using this TEE public key. In one embodiment, transaction Tx1 may also include the above-mentioned report, report signature, signature verification result of the TEE server, and signature of the verification result by the TEE server, so that after uploading this information to the blockchain, other nodes in the blockchain can verify the TEE in node 1 based on this information.

[0062] It can be understood that the TEE in the TEE node of the blockchain is not limited to obtaining the public-private key pair (i.e., sk2 and pk2) for asymmetric encryption or signature verification in the above manner, but can obtain the public-private key pair for asymmetric encryption in any known secure manner.

[0063] Figure 3 is a schematic diagram of the transaction execution process within a TEE node in an embodiment of this specification. As shown in Figure 3, the TEE node includes both a virtual machine outside the TEE and a virtual machine within the TEE. For blockchains that include TEE nodes, in this embodiment, a field 1 is provided for transactions to indicate the transaction type. For example, this field indicates whether the transaction is complex or non-complex. As shown in Figure 3, when executing a transaction, the TEE node first determines whether the transaction is complex based on the value of field 1 in the transaction. If the transaction is non-complex, the transaction is executed via a virtual machine outside the TEE. If the transaction is complex, the transaction is executed via a virtual machine within the TEE, obtaining the transaction's execution read-write set. The TEE then signs the execution read-write set and sends the execution read-write set and its signature to a regular node. After verifying the execution read-write set, the regular node can directly accept the write set within the execution read-write set, storing it as the execution write set for transaction Tx2 without executing the complex transaction Tx2. This improves transaction execution efficiency within the blockchain. The regular node may not include a TEE. It will be understood that although the embodiments of this specification are described using complex transactions as an example, the embodiments of this specification are not limited to executing complex transactions in TEE. For example, a TEE node can execute each transaction in a block in TEE, or a TEE node can execute specific types of transactions in TEE, such as transactions that call specific contracts, etc., without limitation to this.

[0064] Figure 4 is a flow chart of a method for executing a transaction in an embodiment of this specification. This method can be executed by TEE nodes and ordinary nodes in the blockchain.

[0065] As shown in FIG4 , in step S401 , the TEE node executes the complex transaction Tx2 in the TEE.

[0066] For example, consider a blockchain where node 1 is a TEE node and the other nodes are regular nodes without TEEs. As shown in Figure 3, when executing transaction Tx2, for example, node 1 first determines whether it is a complex transaction. If so, it executes Tx2 within the TEE. Specifically, since transaction Tx2 includes the aforementioned field 1, node 1 first reads the value of field 1 in Tx2 and, based on this value, determines whether Tx2 is a complex transaction.

[0067] In the TEE of Node 1, transaction Tx2 can be executed in the virtual machine, obtaining the execution result and execution read-write set of transaction Tx2. The execution result is a transaction receipt returned to the user. The execution read-write set includes an execution read set and an execution write set. The execution read set includes the key-value pairs of variables read during the execution of transaction Tx2, and the execution write set includes the key-value pairs of variables written during the execution of transaction Tx2.

[0068] Before executing transaction Tx2, node 1 may perform a read-write set analysis on transaction Tx2 to obtain an analyzed read-write set of transaction Tx2, which includes an analyzed read set and an analyzed write set. The analyzed read set includes the analyzed identifier of the object that transaction Tx2 will read when executed, and the analyzed key of the variable that transaction Tx2 will write when executed.

[0069] Among them, when transaction Tx2 calls a contract, the variables accessed by transaction Tx2 during execution may include the following three variables:

[0070] In the first case, the state variable A accessed by the contract is a fixed-length variable. The key of variable A in the state database can be determined based on, for example, the declaration location of variable A in the contract. Therefore, the key of variable A to be accessed can be determined before transaction Tx2 is executed. For state variable A accessed in the contract, the key of state variable A can be analyzed and obtained during read-write set analysis of transaction Tx2, and recorded in the analyzed read-write set.

[0071] In the second case, the state variable accessed by the contract (e.g., variable B) is a state variable corresponding to a mapping relationship, wherein variable B is mapped to the information in the transaction body of the transaction that calls the contract Contract1 (e.g., transaction Tx2) according to the mapping relationship. The key of variable B in the state database can be determined based on the identifier of the mapping relationship and the information in transaction Tx2. Therefore, the key of variable B to be accessed can be determined before transaction Tx2 is executed. The mapping relationship is, for example, associated with the sending account of the transaction or the incoming parameters of the transaction to the contract. For example, the contract includes a mapping relationship a[], which is used to map the sending account of the transaction that calls the contract to the state variable a[from]. The value of the state variable a[from] can be determined based on the declaration position of the mapping relationship a[] in the contract and the value of the from field in transaction Tx2. For the state variable B accessed in the contract, when performing read-write set analysis on transaction Tx2, the key of the state variable B can be analyzed and recorded in the analyzed read-write set.

[0072] In the third case, the state variable accessed by the contract is a state variable corresponding to the mapping relationship, and the mapping relationship is associated with the value of the state variable C declared in the contract, and the value of the state variable C needs to be read from the state database. For example, the contract Contract1 includes a mapping relationship e[], which is used to map the state variable C to the state variable e[C]. Since the value of the state variable C cannot be confirmed before the execution of transaction Tx2, the key of the variable e[C] cannot be determined before the execution of transaction Tx2. For the state variable e[C], when performing read-write set analysis on transaction Tx2, the identifier of the mapping relationship e[] can be recorded in the analysis read-write set. By recording the identifier of the mapping relationship e[] in the analysis read-write set instead of the key of the variable e[C], it can be used to group multiple transactions based on the analysis read-write set, wherein the grouping of multiple transactions will be described in detail below with reference to Figure 5.

[0073] Assume that the aforementioned state variables A, B, and e[C] are all read variables in the contract. Before executing transaction Tx, Node 1 can first read the values ​​corresponding to the keys of each state variable in the analysis read set, specifically including the values ​​of state variables A and B, based on the analysis read set obtained above. It then provides transaction Tx2, the analysis read set, and the values ​​of each key in the analysis read set to the TEE. The TEE can then append the pre-read values ​​of each state variable to the analysis read set, execute transaction Tx2 based on the pre-read values ​​of each state variable, obtain the written values ​​of each state variable, and append these written values ​​to the analysis write set. Furthermore, for the aforementioned state variable e[C], the TEE can read the value of state variable C, determine the key of state variable e[C] based on the value of the state variable and the identifier of the mapping relationship e[], read the value of state variable e[C] based on this key, append this key-value pair to the analysis read set, and delete the identifier of the mapping relationship e[] previously recorded in the analysis read set. By modifying the analysis read set in this way, the execution read set of transaction Tx2 can be obtained. That is, the execution read set of transaction Tx2 may include key-value pairs of state variables A, B, and e[C].

[0074] After obtaining the execution read-write set of transaction Tx2, the TEE in node 1 can use the private key pre-stored in the TEE (such as the private key sk2 mentioned above) to sign the execution read-write set for sending to ordinary nodes. In one embodiment, the TEE in node 1 can use the private key sk2 to sign the execution result and the execution read-write set for sending to ordinary nodes.

[0075] In step S403, the TEE node sends the execution read-write set of transaction Tx2 and the TEE's signature on the execution read-write set to the ordinary node.

[0076] The TEE node can send the execution read / write set of transaction Tx2 and the TEE's signature on the execution read / write set to each ordinary node in the blockchain, so that each ordinary node does not need to execute the complex transaction. In one embodiment, the TEE node can send the execution read / write set of transaction Tx2, the transaction receipt, and the TEE's signature on the execution read / write set and the transaction receipt to each ordinary node in the blockchain.

[0077] The following description uses node 2 as an example of a common node. It is understood that other common nodes in the blockchain can operate similarly to node 2.

[0078] In step S405, the ordinary node verifies the signature, and after verifying the signature, verifies the execution read set of the received transaction Tx2.

[0079] Node 2 can query the public key (e.g., pk2) of the TEE in Node 1 in advance from the contract status of the system contract. When executing transaction Tx2, Node 2 first determines that transaction Tx2 is a complex transaction based on field 1 in transaction Tx2. Then, Node 2 determines whether it has received the execution read-write set and signature of transaction Tx2 from Node 1. If not, it waits. If Node 2 does not receive the execution read-write set and signature of transaction Tx2 after waiting for a preset time, it can continue to execute transaction Tx2 normally.

[0080] After receiving the execution read / write set and signature of transaction Tx2 from node 1 within the preset time, node 2 can verify the received TEE signature using public key pk2. By verifying the signature, node 2 can confirm that the execution read / write set of transaction Tx2 received is indeed the execution read / write set generated by the TEE executing transaction Tx2.

[0081] After node 2 verifies the signature, it can verify the execution read set of the received transaction Tx2.

[0082] Node 2 can perform read-write set analysis on transaction Tx2 similarly to node 1, obtaining an analyzed read-write set for transaction Tx2. The analyzed read-write set includes, for example, the keys of state variables A and B and the identifier of the mapping relationship e[]. Upon determining that the received execution read set includes the keys of state variables A and B and the identifier of the mapping relationship e[], node 2 reads the current values ​​of state variables A and B and determines whether the values ​​of state variables A and B in the execution read set are consistent with the read current values ​​of state variables A and B. If they are consistent, verification of state variables A and B succeeds.

[0083] Node 2 can then determine that the state variable e[C] is the state variable that TEE determined needs to read during the execution of transaction Tx2. Therefore, node 2 can trust the key of the state variable e[C] and read the current value of the state variable e[C] to determine whether the value of the state variable e[C] in the executed read set is consistent with the current value of the read state variable e[C]. If they are consistent, the verification of the state variable e[C] is passed.

[0084] If node 2 determines that the execution read set does not include any of the keys of state variables A and B and the identifiers of the mapping relationship e[], or that the values ​​of state variables A and B in the execution read set are inconsistent with the current values ​​of state variables A and B read, or that the value of state variable e[C] in the execution read set is inconsistent with the current value of state variable e[C] read, then the verification of the execution read set of transaction Tx2 can be confirmed to have failed. If the verification of the execution read set of transaction Tx2 fails, node 2 can continue to execute transaction Tx2 normally.

[0085] In step S407, if the verification is successful, node 2 stores the execution write set of the received transaction Tx2.

[0086] After all the above verifications are passed, node 2 can confirm that the execution write-set of transaction Tx2 received from node 1 is the correct write-set. Therefore, it can store the received execution write-set as the execution write-set of transaction Tx2 without executing transaction Tx2 again.

[0087] Through this transaction execution solution, ordinary nodes do not need to execute complex transactions, which saves computing resources in the blockchain and improves the transaction execution efficiency of the blockchain.

[0088] FIG5 is a flow chart of a transaction execution method in another embodiment of the present specification.

[0089] As shown in FIG5 , first, in step S501 , the TEE node obtains analysis read-write sets of multiple transactions and groups the multiple transactions according to the analysis read-write sets of the multiple transactions.

[0090] The TEE node can determine the analysis read-write set for each transaction by analyzing the data corresponding to each transaction. In one embodiment, when a contract is deployed, the storage location information of the state variables read and written by the contract can be stored in the contract state along with the contract code. The TEE node can then read the storage location information of the state variables read and written by the contract from the blockchain and obtain the analysis read-write set for each transaction based on this information.

[0091] The TEE node can then determine access conflicts between transactions based on their analyzed read-write sets, thereby grouping multiple transactions so that transactions with access conflicts are grouped together into a single transaction group, while preventing access conflicts between different transaction groups. Specifically, multiple transactions can be identified as having access conflicts if: their analyzed write sets contain the same key; or the analyzed write set of one transaction in the multiple transactions contains the same key as the analyzed read set of another transaction.

[0092] After grouping the multiple transactions, the TEE node obtains four transaction groups G1, G2, G3 and G4, for example. It is assumed that the transaction group G1 includes the complex transaction Tx2, and the transaction groups G2-G4 do not include complex transactions.

[0093] In step S503 , the common node obtains the analyzed read-write sets of the multiple transactions and groups the multiple transactions according to the analyzed read-write sets.

[0094] This step can refer to the description of step S501 above. Ordinary nodes can use the same method as TEE nodes to obtain the analysis read-write set of each transaction and group multiple transactions to obtain transaction groups G1', G2', G3', and G4'. Assume that transaction group G1' includes the complex transaction Tx2, and transaction groups G2'-G4' do not include complex transactions. In the case that the TEE node does not act maliciously, transaction groups G1', G2', G3', and G4' should be the same as transaction groups G1, G2, G3, and G4.

[0095] In step S505 , the TEE node executes the transaction group G1 including the complex transaction Tx2 .

[0096] After determining that transaction group G1 includes a complex transaction, the TEE node prioritizes transaction group G1. For example, if the TEE node includes two threads for executing transactions, the two threads will first execute transaction group G1 and any transaction group from G2-G4 (e.g., transaction group G4). During step S505, the TEE node executes step S5051, executing transaction Tx2 in the TEE. This step can be referred to the description of step S401 above and will not be repeated here.

[0097] In step S507 , the common node executes the transaction group that does not include the complex transaction.

[0098] Taking Node 2 as an example, Node 2 can prioritize executing transaction groups that do not include complex transactions, thereby minimizing the time it takes to wait for the TEE node to execute complex transactions. Specifically, if Node 2 includes two threads for executing transactions, Node 2 can first execute transaction groups G2' and G3' in parallel. After completing the execution of transaction groups G2' and G3', it can then start executing transaction groups G1' and G4'.

[0099] In step S509, the TEE node sends the execution read-write set of transaction Tx2 and the TEE's signature on the read-write set to the ordinary node.

[0100] This step can refer to the description of step S403 above, which will not be repeated here.

[0101] In step S511 , the TEE node executes a transaction group that does not include complex transactions.

[0102] After executing transaction groups G1 and G4 in parallel, the TEE node can continue to execute transaction groups G2 and G3 in parallel.

[0103] In step S513 , the ordinary node executes the transaction group G1 ′ including the transaction Tx2 .

[0104] For example, after completing the execution of transaction groups G2′ and G3′, node 2 executes transaction groups G1′ and G4′ in parallel. When node 2 executes transaction Tx2, it determines that the execution read-write set and signature of transaction Tx2 have been received from the TEE node. It executes steps S5131 and S5132, so that it can directly accept the execution write set of transaction Tx2 sent by node 1 without executing transaction Tx2. At the same time, due to the scheduling of transaction group G1′ by node 2, it is guaranteed that node 2 has received the execution read-write set and signature of transaction Tx2 when executing transaction Tx2, thereby reducing the waiting time of node 2. Among them, steps S5131 and S5132 can refer to the description of steps S405 and S407 above, and will not be repeated here.

[0105] FIG6 is an architecture diagram of a first node in a blockchain according to an embodiment of this specification. The blockchain includes a first node and a second node. The first node includes a TEE. The first node is configured to execute the method shown in FIG4 or FIG5 , including:

[0106] An execution unit 61 is configured to execute a first transaction in the TEE to obtain a first execution read-write set of the first transaction, where the first execution read-write set includes a first execution read set and a first execution write set.

[0107] A signing unit 62 is configured to sign the first execution read-write set using a private key stored in the TEE to obtain a first signature;

[0108] The sending unit 63 is configured to send the first execution read-write set and the first signature to the second node.

[0109] FIG7 is an architectural diagram of a second node in a blockchain according to an embodiment of this specification. The blockchain includes a first node and a second node. The first node includes a TEE. The second node is configured to execute the method shown in FIG4 or FIG5 , including:

[0110] A receiving unit 71 is configured to receive, from the first node, a first execution read-write set of a first transaction and a first signature of the first execution read-write set generated by the TEE using a private key stored in the TEE, where the first execution read-write set includes a first execution read set and a first execution write set;

[0111] a verification unit 72 configured to verify the first signature using a public key corresponding to the private key; and after the verification of the first signature is successful, verify the first execution read set;

[0112] The storage unit 73 is configured to store the first execution write set as the execution write set of the first transaction if verification of the first execution read set is passed.

[0113] The embodiments of this specification also provide a computer-readable storage medium having a computer program stored thereon. When the computer program is executed in a computer, the computer is caused to execute the method shown in FIG. 4 or FIG. 5 .

[0114] An embodiment of this specification also provides a blockchain node, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method shown in Figure 4 or Figure 5 is implemented.

[0115] In the 1990s, technological improvements could be clearly distinguished as either hardware improvements (for example, improvements to circuit structures like diodes, transistors, and switches) or software improvements (improvements to process flows). However, with the advancement of technology, many process flow improvements today can now be considered direct improvements to hardware circuit structures. Designers almost always create the corresponding hardware circuit structure by programming the improved process flow into the hardware circuit. Therefore, it cannot be said that a process flow improvement cannot be implemented using hardware modules. For example, a programmable logic device (PLD), such as a field programmable gate array (FPGA), is an integrated circuit whose logical function is determined by user programming. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to hire a chip manufacturer to design and manufacture a dedicated integrated circuit chip. Moreover, nowadays, instead of manually fabricating integrated circuit chips, this programming is mostly done using "logic compiler" software. This is similar to the software compiler used when developing programs. Before compilation, the original code must also be written in a specific programming language, called a hardware description language (HDL). There is not just one HDL, but many, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art will also understand that by simply programming the method flow in one of these hardware description languages ​​and then programming it into an integrated circuit, a hardware circuit that implements the logic method flow can be easily obtained.

[0116] The controller can be implemented in any suitable manner. For example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also know that in addition to implementing the controller in a purely computer-readable program code format, the controller can be implemented in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, such a controller can be considered a hardware component, and the devices included therein for implementing various functions can also be considered as structures within the hardware component. Or even, the devices for implementing various functions can be considered as both software modules that implement the method and structures within the hardware component.

[0117] The systems, devices, modules or units illustrated in the above embodiments may be implemented by computer chips or entities, or by products having certain functions. A typical implementation device is a server system. Of course, the present application does not exclude that with the development of computer technology in the future, the computer that implements the functions of the above embodiments may be, for example, a personal computer, a laptop computer, a vehicle-mounted human-computer interaction device, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device or a combination of any of these devices. Although one or more embodiments of this specification provide method operation steps as described in the embodiments or flow charts, more or fewer operation steps may be included based on conventional or non-creative means. The order of steps listed in the embodiments is only one way of executing the order of many steps and does not represent the only order of execution. When the device or terminal product in practice is executed, it may be executed sequentially or in parallel according to the method shown in the embodiments or the accompanying drawings (for example, in an environment of parallel processors or multi-threaded processing, or even in a distributed data processing environment). The terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, product, or apparatus that includes a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, product, or apparatus. Without further limitation, it does not preclude the presence of additional identical or equivalent elements in the process, method, product, or apparatus that includes the elements. For example, the terms first, second, etc., when used, are used to indicate names and do not imply any particular order.

[0118] For the convenience of description, the above devices are described in terms of functions divided into various modules. Of course, when implementing one or more of the present specifications, the functions of each module can be implemented in the same or multiple software and / or hardware, or the module that implements the same function can be implemented by a combination of multiple sub-modules or sub-units, etc. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0119] The present invention is described with reference to the flowcharts and / or block diagrams of the methods, apparatus (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for implementing the functions specified in one or more processes in the flowchart and / or one or more blocks in the block diagram.

[0120] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.

[0121] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.

[0122] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory. Memory may include non-permanent storage in a computer-readable medium, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0123] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic disk storage, graphene storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory media such as modulated data signals and carrier waves.

[0124] Those skilled in the art will appreciate that one or more embodiments of this specification may be provided as a method, system, or computer program product. Thus, one or more embodiments of this specification may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, one or more embodiments of this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0125] One or more embodiments of this specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. One or more embodiments of this specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communications network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0126] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between the various embodiments can be referenced across them. Each embodiment focuses on the differences from the other embodiments. In particular, since the system embodiments are generally similar to the method embodiments, their description is relatively simple. For relevant parts, reference can be made to the description of the method embodiments. Throughout this specification, reference to the terms "one embodiment," "some embodiments," "examples," "specific examples," or "some examples" means that the specific features, structures, materials, or characteristics described in conjunction with that embodiment or example are included in at least one embodiment or example of this specification. In this specification, the schematic representations of these terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, those skilled in the art may combine and integrate the different embodiments or examples, and features of different embodiments or examples, described in this specification, without conflict.

[0127] The foregoing description is merely an example of one or more embodiments of this specification and is not intended to limit the one or more embodiments of this specification. Those skilled in the art will appreciate that various modifications and variations of one or more embodiments of this specification are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of this specification are intended to be included within the scope of the claims.

Claims

1. A transaction execution method in a blockchain, wherein the blockchain includes a first node and a second node, wherein the first node includes a TEE, and the method includes: The first node executes a first transaction in the TEE to obtain a first execution read-write set of the first transaction, and signs the first execution read-write set using a private key stored in the TEE to obtain a first signature, wherein the first execution read-write set includes a first execution read set and a first execution write set; Sending the first execution read-write set and the first signature to the second node; The second node verifies the first signature using the public key corresponding to the private key, and after the verification of the first signature is passed, verifies the first execution read set, and if the verification is passed, stores the first execution write set as the execution write set of the first transaction.

2. The method according to claim 1, wherein verifying the first execution read set comprises: The second node performs a read-write set analysis on the first transaction to obtain a second analysis read set of the first transaction, wherein the second analysis read set of the first transaction includes keys of several first variables; in the case where it is determined that the first execution read set includes the keys of the several first variables, the first values ​​of the several first variables are read; and it is determined whether the first value is consistent with the values ​​of the several first variables in the first execution read set, and if they are inconsistent, the verification of the first execution read set fails.

3. The method according to claim 2, wherein the first execution read set further includes a plurality of key-value pairs of the second variable, and the verifying the first execution read set includes: Reading second values ​​of the plurality of second variables; It is determined whether the second value is consistent with the values ​​of the plurality of second variables in the first execution read set; if not, verification of the first execution read set fails.

4. The method according to claim 2, wherein the first transaction is a preset type transaction, and the method further comprises: The first node performs read-write set analysis on the multiple transactions respectively to obtain first analyzed read-write sets of the multiple transactions; Grouping the multiple transactions according to the multiple first analysis read-write sets to obtain multiple transaction groups, wherein the multiple transaction groups include a first transaction group and a second transaction group, wherein the first transaction group includes the first transaction, and the second transaction group does not include transactions of the preset type; The first node executing the first transaction in the TEE includes: The first node executes transactions of the first transaction group before executing transactions of the second transaction group.

5. The method according to claim 4, wherein each transaction includes a first field for indicating whether the transaction is a transaction of the preset type, and the first node executing the first transaction in the TEE includes: The first node determines that the first transaction is a transaction of the preset type according to the first field of the first transaction, provides the first transaction to the TEE, and executes the first transaction in the TEE.

6. According to the method of claim 5, the second node performing read-write set analysis on the first transaction comprises: The second node performs read-write set analysis on the multiple transactions respectively to obtain second analyzed read-write sets of the multiple transactions; The method further comprises: The second node groups the multiple transactions according to the multiple second analysis read-write sets to obtain multiple transaction groups, wherein the multiple transaction groups include a third transaction group and a fourth transaction group, the third transaction group includes the first transaction, and the fourth transaction group does not include transactions of the preset type; The second node executes the transactions of the fourth transaction group before executing the transactions of the third transaction group.

7. The method according to claim 6, further comprising: When the second node executes the first transaction in the third transaction group, after determining that the first transaction is the preset type of transaction according to the first field of the first transaction, it determines whether the first execution read-write set and the first signature of the first transaction are received from the first node, and waits if it is determined that the first execution read-write set and the first signature are not received from the first node.

8. According to the method of claim 1, a system contract is deployed in the blockchain, and the public key is stored in the contract state of the system contract, and the method further comprises: The second node obtains the public key by querying the contract status of the system contract.

9. The method according to claim 7, wherein the second node executes the first transaction in the case where the waiting timeout occurs or the verification of the first execution read set fails.

10. The method according to claim 1, wherein the first node executes a first transaction in the TEE to obtain a first execution read-write set of the first transaction, and signs the first execution read-write set using a private key stored in the TEE to obtain a first signature; Sending the first execution read-write set and the first signature to the second node; comprising: The first node executes a first transaction in the TEE, obtains a first execution read-write set and a transaction receipt of the first transaction, signs the first execution read-write set and the transaction receipt using a private key stored in the TEE to obtain a first signature; and sends the first execution read-write set, the transaction receipt, and the first signature to the second node.

11. A transaction execution method in a blockchain, wherein the blockchain includes a first node and a second node, the first node includes a TEE, and the method is executed by the first node, comprising: Execute a first transaction in the TEE to obtain a first execution read-write set of the first transaction; Signing the first execution read-write set using the private key of the TEE to obtain a first signature; The first execution read-write set and the first signature are sent to the second node.

12. A transaction execution method in a blockchain, wherein the blockchain includes a first node and a second node, the first node includes a TEE, and the method is executed by the second node, comprising: receiving, from the first node, a first execution read-write set of a first transaction and a first signature of the first execution read-write set generated by the TEE using a private key stored in the TEE, wherein the first execution read-write set includes a first execution read set and a first execution write set; Verifying the first signature using a public key corresponding to the private key; After the verification of the first signature is passed, verifying the first execution read set; When verification of the first execution read set passes, the first execution write set is stored as the execution write set of the first transaction.

13. A blockchain system, comprising a first node and a second node, wherein the first node comprises a TEE, The first node is used to: execute a first transaction in the TEE to obtain a first execution read-write set of the first transaction, sign the first execution read-write set using a private key stored in the TEE to obtain a first signature, wherein the first execution read-write set includes a first execution read set and a first execution write set; and send the first execution read-write set and the first signature to the second node; The second node is used to: verify the first signature using the public key corresponding to the private key, After the first signature is verified, the first execution read set is verified, and if the verification is passed, the first execution write set is stored as the execution write set of the first transaction.

14. A first node in a blockchain, the blockchain comprising a first node and a second node, the first node comprising a TEE, the first node comprising: An execution unit, configured to execute a first transaction in the TEE to obtain a first execution read-write set of the first transaction; A signing unit, configured to sign the first execution read-write set using a private key stored in the TEE to obtain a first signature; A sending unit is used to send the first execution read-write set and the first signature to the second node.

15. A second node in a blockchain, the blockchain comprising a first node and a second node, the first node comprising a TEE, and the second node comprising: a receiving unit, configured to receive, from the first node, a first execution read-write set of a first transaction and a first signature of the first execution read-write set generated by the TEE by using a private key stored in the TEE, wherein the first execution read-write set includes a first execution read set and a first execution write set; a verification unit, configured to verify the first signature using a public key corresponding to the private key; and verify the first execution read set after the first signature is verified; A storage unit is used to store the first execution write set as the execution write set of the first transaction when verification of the first execution read set is passed.

16. A blockchain node, comprising a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method as claimed in claim 11 or 12 is implemented.

Citation Information

Patent Citations

  • Method for executing transaction in block chain system, block chain system and node

    CN115098594A

  • Transaction execution method and block chain node

    CN115714652A

  • Transaction grouping method and block chain node

    CN115758333A

  • Read-write set generation method of private transaction and block chain node

    CN115906121A

  • Transaction execution method, node and system in block chain

    CN116561740A