Transaction scheduling method and device
By determining the amount of private transaction data on the blockchain node and packaging it, and using the trusted execution environment to solve privacy and performance issues, it is possible to improve the security and privacy of the blockchain without losing performance, and Reduces transaction processing overhead.
Patent Information
- Application Number
- CN202110065073.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-08-30
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2039-08-30
AI Technical Summary
When existing blockchain technology solves privacy and performance issues, it is often difficult to take both privacy and performance into account. Common encryption technologies are highly complex and have poor versatility, resulting in performance losses. Although the trusted execution environment can improve security and privacy, it is High-frequency trading may cause greater overhead and affect efficiency.
Determine the amount of private transaction data received through the blockchain node, and package multiple private transactions through a single function call and transfer it to the trusted execution environment if it is not greater than the preset threshold, reducing the number of function calls and reducing costs. overhead.
Significantly improve the security and privacy of the blockchain without losing performance, reduce the overhead of private transaction transmission, and improve transaction processing efficiency.
Smart Images

Figure CN112765610B
Abstract
Description
Technical Field
[0001] One or more embodiments of the present specification relate to the field of blockchain technology, and more particularly, to a transaction scheduling method and device. Background Art
[0002] Blockchain technology is built on top of a transmission network (such as a peer-to-peer network). Network nodes in the transmission network use chain data structures to verify and store data, and use distributed node consensus algorithms to generate and update data.
[0003] The two biggest technical challenges for enterprise-level blockchain platforms are privacy and performance, and it is often difficult to solve these two challenges at the same time. Most solutions sacrifice performance in exchange for privacy, or pursue performance without considering privacy. Common encryption technologies that solve privacy issues, such as homomorphic encryption and zero-knowledge proof, are highly complex, have poor versatility, and may also cause serious performance losses.
[0004] Trusted Execution Environment (TEE) is another way to solve the privacy problem. TEE can act as a black box in hardware. The code and data executed in TEE cannot be peeped at by the operating system layer. Only the pre-defined interfaces in the code can operate on them. In terms of efficiency, due to the black box nature of TEE, the calculations in TEE are plain text data, not complex cryptographic operations in homomorphic encryption, and the efficiency of the calculation process is not lost. Therefore, combining with TEE can greatly improve the security and privacy of blockchain with little performance loss. At present, the industry pays great attention to the TEE solution. Almost all mainstream chip and software alliances have their own TEE solutions, including TPM (Trusted Platform Module) in software and Intel SGX (Software Guard Extensions), ARM Trustzone and AMD PSP (Platform Security Processor) in hardware. Summary of the invention
[0005] In view of this, one or more embodiments of the present specification provide a transaction scheduling method and device.
[0006] To achieve the above objectives, one or more embodiments of this specification provide the following technical solutions:
[0007] According to a first aspect of one or more embodiments of this specification, a transaction scheduling method is proposed, including:
[0008] The blockchain node determines the amount of data received for the private transaction;
[0009] The blockchain node packages multiple privacy transactions whose total data volume is not greater than a preset threshold and transmits them to the trusted execution environment through a single function call;
[0010] Among them, when the amount of incoming data is not greater than the preset threshold, the first amount of overhead generated by the single function call is independent of the amount of incoming data; when the amount of incoming data is greater than the preset threshold, the second amount of overhead generated by the single function call is greater than the first amount of overhead and is positively correlated with the amount of incoming data.
[0011] According to a second aspect of one or more embodiments of this specification, a transaction scheduling device is provided, including:
[0012] A determination unit that enables blockchain nodes to determine the amount of data received for private transactions;
[0013] A transmission unit, which enables the blockchain node to package multiple privacy transactions whose sum of data volume is not greater than a preset threshold and transmit them to the trusted execution environment through a single function call;
[0014] Among them, when the amount of incoming data is not greater than the preset threshold, the first amount of overhead generated by the single function call is independent of the amount of incoming data; when the amount of incoming data is greater than the preset threshold, the second amount of overhead generated by the single function call is greater than the first amount of overhead and is positively correlated with the amount of incoming data.
[0015] According to a third aspect of one or more embodiments of this specification, an electronic device is provided, including:
[0016] processor;
[0017] a memory for storing processor-executable instructions;
[0018] The processor implements the method as described in the first aspect by running the executable instructions.
[0019] According to a fourth aspect of one or more embodiments of the present specification, a computer-readable storage medium is provided, on which computer instructions are stored, and when the instructions are executed by a processor, the steps of the method described in the first aspect are implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 It is a schematic diagram of a blockchain node processing a transaction provided by an exemplary embodiment.
[0021] Figure 2 It is a flow chart of a transaction scheduling method provided by an exemplary embodiment.
[0022] Figure 3 It is a schematic diagram of creating a smart contract provided by an exemplary embodiment.
[0023] Figure 4 This is a schematic diagram of calling a smart contract provided by an exemplary embodiment.
[0024] Figure 5 It is a schematic diagram of the changing relationship between the amount of incoming data and the amount of overhead provided by an exemplary embodiment.
[0025] Figure 6 It is a structural schematic diagram of a device provided by an exemplary embodiment.
[0026] Figure 7 It is a block diagram of a transaction scheduling device provided by an exemplary embodiment. DETAILED DESCRIPTION
[0027] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of this specification. Instead, they are merely examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.
[0028] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may be combined into a single step for description in other embodiments.
[0029] Blockchain is generally divided into three types: public blockchain, private blockchain and consortium blockchain. In addition, there are many types of combinations, such as private blockchain + consortium blockchain, consortium blockchain + public blockchain and other different combinations. Among them, the public chain has the highest degree of decentralization. Ethereum is a representative of the public chain. Participants who join the public chain can read the data records on the chain, participate in transactions, and compete for the right to record new blocks. Moreover, each participant (i.e., node) can freely join and exit the network and perform related operations. On the contrary, the private chain has the write permission of the network controlled by a certain organization or institution, and the data reading permission is stipulated by the organization. In simple terms, the private chain can be a weakly centralized system with strictly limited and few participating nodes. This type of blockchain is more suitable for use within a specific institution. The consortium chain is a blockchain between the public chain and the private chain, which can achieve "partial decentralization". Each node in the consortium chain usually has a corresponding entity or organization; participants join the network through authorization and form a stakeholder alliance to jointly maintain the operation of the blockchain.
[0030] Regardless of whether it is a public chain, a private chain, or a consortium chain, nodes in the blockchain network may execute received transactions within the TEE (Trusted Execution Environment) for the purpose of privacy protection through a solution that combines blockchain with TEE. Figure 1 As shown, the blockchain node includes a regular execution environment on the left and a trusted execution environment (TEE) on the right. Transactions submitted by the client (or other sources) first enter the "transaction scheduling" interface in the regular execution environment for type identification, and the identified plaintext transactions are left in the regular execution environment for processing (corresponding to the "transaction execution" link on the left), while the identified privacy transactions are passed to TEE for processing (corresponding to the "transaction execution" link on the right).
[0031] TEE is a trusted execution environment that is completely isolated from the outside world and is based on the security extension of CPU hardware. TEE was first proposed by Global Platform to solve the security isolation of resources on mobile devices and provide a trusted and secure execution environment for applications in parallel with the operating system. ARM's Trust Zone technology was the first to realize the real commercial TEE technology. With the rapid development of the Internet, the demand for security is getting higher and higher, not only for mobile devices, but also for cloud devices and data centers. The concept of TEE has also been rapidly developed and expanded. The TEE mentioned now is a more generalized TEE than the concept originally proposed. For example, server chip manufacturers Intel, AMD, etc. have successively launched hardware-assisted TEE and enriched the concept and characteristics of TEE, which has been widely recognized in the industry. The TEE mentioned now usually refers more to this type of hardware-assisted TEE technology. Unlike mobile terminals, cloud access requires remote access, and the end user is invisible to the hardware platform. Therefore, the first step in using TEE is to confirm the authenticity of TEE. Therefore, the current TEE technology has introduced a remote proof mechanism, which is endorsed by hardware manufacturers (mainly CPU manufacturers) and uses digital signature technology to ensure that users can verify the status of TEE. At the same time, security resource isolation alone cannot meet security needs, and further data privacy protection has also been proposed. Commercial TEEs including Intel SGX and AMD SEV also provide memory encryption technology, which limits trusted hardware to the CPU. The data on the bus and memory are all encrypted to prevent malicious users from snooping. For example, TEE technologies such as Intel's Software Guard Extensions (SGX) isolate code execution, remote attestation, secure configuration, secure storage of data, and trusted paths for executing code. Applications running in TEE are securely protected and almost impossible to be accessed by third parties.
[0032] Taking Intel SGX technology as an example, SGX provides an enclave, which is an encrypted trusted execution area in memory, where the CPU protects data from being stolen. Taking the first blockchain node using a CPU that supports SGX as an example, using the newly added processor instructions, a part of the area EPC (Enclave Page Cache) can be allocated in the memory, and the data in it can be encrypted through the encryption engine MEE (Memory Encryption Engine) in the CPU. The encrypted content in EPC will only be decrypted into plaintext after entering the CPU. Therefore, in SGX, users can distrust the operating system, VMM (Virtual Machine Monitor), and even BIOS (Basic Input Output System), and only need to trust the CPU to ensure that private data will not be leaked. In actual applications, private data can be encrypted and passed to the enclave in ciphertext form, and the corresponding secret key can also be passed to the enclave through remote proof. Then, the data is used for calculation under the encryption protection of the CPU, and the result will be returned in ciphertext form. In this mode, you can take advantage of powerful computing power without worrying about data leakage.
[0033] In related technologies, blockchain nodes can use ECall operations to implement function calls inside enclaves, thereby transferring private transactions from regular execution environments to TEEs. Then, when blockchain nodes receive transactions frequently, each transaction needs to be transferred to TEEs separately through ECall operations, which may result in relatively large overhead and affect the transaction processing efficiency of blockchain nodes.
[0034] The following describes a transaction scheduling method provided in this specification in combination with an embodiment, which can relatively reduce the overhead generated when transmitting private transactions.
[0035] Figure 2 FIG. 1 is a flow chart of a transaction scheduling method provided by an exemplary embodiment. Figure 2 As shown, the method may include the following steps:
[0036] In step 202, the blockchain node determines the amount of data of the received private transaction.
[0037] Privacy transactions can be understood as transactions with privacy requirements. In addition to privacy transactions, blockchain nodes may receive plaintext transactions, which are transactions without privacy requirements. Privacy requirements can be expressed in many ways, and this specification does not limit this. For example, each transaction can contain a type field, which is used to mark whether the corresponding transaction is a privacy transaction or a plaintext transaction. As mentioned above, blockchain nodes can Figure 1 The "transaction scheduling" interface in the conventional execution environment shown identifies the transaction type. In the related art, for example, in the Ethereum network, transactions usually contain fields such as to, value, and data; and this embodiment, based on the related art, adds a type field to the transaction, such as a type field, and indicates the type of the related transaction based on the value of the type field: for example, when the type field is the first value, it indicates that the related transaction is a plaintext transaction, and when the type field is the second value, it indicates that the related transaction is a private transaction. For another example, the user can add an encryption identifier to the transaction during the creation of the transaction to express the above-mentioned privacy requirements. Then, when it is checked that the transaction contains an encryption identifier, the blockchain node can determine that the transaction is a private transaction, otherwise it is determined that the transaction is a plaintext transaction. For another example, the blockchain node can identify the type of smart contract that the transaction needs to call. When the called smart contract belongs to the privacy type (for example, the smart contract contains a privacy identifier, or the smart contract code includes the contract state marked with a privacy identifier, etc.), it can be determined that the transaction belongs to a private transaction, otherwise it is determined that the transaction is a plaintext transaction.
[0038] The transaction received by the blockchain node may come from the client; for example, after the user generates the transaction on the client, the user may submit the transaction to the above blockchain node through the client. Alternatively, the transaction may be forwarded to the above blockchain node by other blockchain nodes; for example, after the user generates the transaction on the client, the user may submit the transaction to other blockchain nodes through the client, so that the other blockchain nodes may forward the transaction to the above blockchain node. Alternatively, the user may directly generate the above transaction at the blockchain node.
[0039] For example, in a blockchain network that uses consensus algorithms such as Proof of Work (POW), Proof of Stake (POS), and Delegated Proof of Stake (DPOS), after receiving the transaction submitted by the client, each blockchain node immediately spreads (such as broadcasting) it to the other blockchain nodes in the Ethereum network. Therefore, the transactions received by the above blockchain nodes may include transactions spread by other blockchain nodes in the blockchain network.
[0040] For example, in a blockchain network that adopts mechanisms such as Practical Byzantine Fault Tolerance (PBFT), the accounting nodes have been agreed upon before this round of accounting. Assuming that the above blockchain node is determined as an accounting node, after receiving the transaction submitted by the client, other blockchain nodes need to send the transaction to the determined accounting node because they are not accounting nodes themselves, so that the accounting node will package the transaction (including the transaction) and send it to each verification node in the further consensus stage. When another blockchain node other than the above blockchain node is a determined accounting node, the remaining blockchain nodes can forward the transaction to the other blockchain node after receiving the transaction submitted by the client; then, the other blockchain node can package the above transaction (or other transactions) and send it to each verification node in the consensus stage, and when the above blockchain node is a verification node, it can receive the transaction forwarded by the other blockchain node.
[0041] The data volume of a private transaction can be understood as the size of the private transaction, that is, the memory size required for the private transaction, such as 5 bytes or any other size, which depends on the amount of content contained in the private transaction itself. Similarly, plaintext transactions also have a corresponding amount of data, but since plaintext transactions can be directly processed in the regular execution environment of the blockchain node without being passed to the TEE through a function call, the data volume of plaintext transactions has not been focused on in this embodiment.
[0042] In step 204, the blockchain node packages multiple privacy transactions whose total data volume is not greater than a preset threshold into a trusted execution environment through a single function call.
[0043] The blockchain node transfers the private transaction to the TEE through a function call, such as the aforementioned ECall operation. In the related art, each time a blockchain node executes a function call, it only transfers one private transaction to the TEE; in this embodiment, the blockchain node only executes one function call, that is, the above-mentioned single function call, and can package multiple private transactions and transfer them to the TEE, reducing the number of executions of the function call.
[0044] Through the experimental testing of the process of blockchain nodes using function calls to pass private transactions to TEE, this specification found the relationship between the amount of data passed in and the overhead: when the amount of data passed in is not greater than the preset threshold, the first amount of overhead generated by a single function call is independent of the amount of data passed in, and when the amount of data passed in is greater than the preset threshold, the second amount of overhead generated by a single function call is greater than the first amount of overhead and is positively correlated with the amount of data passed in. Therefore, in this specification, multiple private transactions are packaged and passed into TEE through a single function call, and it is ensured that the amount of data passed in (i.e., the sum of the amount of data of multiple private transactions) is not greater than the preset threshold, so that the overhead of the single function call is only the first amount of overhead; assuming that the number of private transactions is N, the overhead of the above single function call is only the first amount of overhead S, and when N private transactions are passed into TEE through N function calls respectively, the overhead generated is S×N, that is, the technical solution of this specification saves S×(N-1) amount of overhead. At least in some embodiments, the above-mentioned preset threshold may not be greater than the pre-allocated space size of the EPC on the blockchain node, and thus the value of the above-mentioned preset threshold may be determined according to the pre-allocated space size of the EPC; of course, the value of the preset threshold may be determined through actual testing, and the value may be related to or unrelated to the pre-allocated space size of the EPC, and this specification does not limit this.
[0045] Among them, when the amount of incoming data satisfies not greater than a preset threshold, when the amount of incoming data changes, the value of the first overhead amount remains unchanged or basically unchanged (the change is small, such as less than or much smaller than the change of the second overhead amount; among them, the change of the first overhead amount is an irregular and accidental change).
[0046] Blockchain nodes can use a buffer mechanism to manage the received private transactions to form a buffer queue consisting of private transactions. These private transactions can be arranged in the buffer queue in order from early to late in the order of reception time, waiting for the blockchain node to pass these private transactions into the TEE through function calls. Among them, after receiving any private transaction, the blockchain node can add the data volume of any private transaction to the data volume of all private transactions in the buffer queue, and compare the obtained addition value with the above-mentioned preset threshold: when the addition value is not greater than the preset threshold, it indicates that the amount of incoming data that can be carried by a single function call can be larger, so the blockchain node can add any private transaction to the buffer queue, waiting to be packaged together with the subsequently received private transactions and transmitted to the TEE; when the addition value is greater than the preset threshold, it indicates that a single function call cannot transmit all private transactions that the blockchain node has received and has not yet transmitted to the TEE (that is, all private transactions in the buffer queue and any of the above-mentioned private transactions recently received) to the TEE, but it can be determined from the above that a single function call can definitely carry all private transactions in the buffer queue, so the blockchain node can package all private transactions in the buffer queue and transmit them to the trusted execution environment, so that the buffer queue is emptied, and then add any of the above-mentioned private transactions to the cleared buffer queue, and any of the above-mentioned private transactions is used as the first private transaction in the buffer queue, and waits to be packaged together with the subsequently received private transactions and transmitted to the TEE.
[0047] Through the above method, the blockchain node can pass as many private transactions as possible into the TEE each time a single function call is implemented, thereby minimizing the overhead generated by the blockchain node. However, in some special cases, the overhead of the blockchain node may not always achieve the above optimal situation. For example, when the amount of data of any private transaction received by the blockchain node exceeds the above preset threshold, the blockchain node needs to pass the private transaction to the TEE separately through a single function call. The overhead generated at this time is the second overhead amount mentioned above and cannot be maintained at the first overhead amount; if the buffer queue also contains other private transactions when receiving any private transaction, then as mentioned above: the blockchain node needs to execute a single function call to pass all private transactions in the buffer queue into the TEE, regardless of whether the number of private transactions in the buffer queue is one or more and how much the sum of the data amounts differs from the preset threshold. For another example, the blockchain node can record the waiting time of the first private transaction in the buffer queue (which can be calculated from the time the first private transaction is received or added to the buffer queue), and when the waiting time reaches the preset time, all private transactions in the buffer queue are packaged and transmitted to the trusted execution environment, which can avoid the long waiting time caused by the generally small amount of private transactions or the low frequency of private transactions, which delays the timely processing of the first private transaction. For another example, the blockchain node may receive private transactions and plaintext transactions alternately. Then, when receiving the plaintext transaction, the blockchain node can immediately package all private transactions in the buffer queue and transmit them to the trusted execution environment, and the blockchain node can execute the above plaintext transactions received outside the TEE, so that all transactions can be executed in sequence to avoid confusion.
[0048] When creating a private transaction, the transaction initiator can encrypt the transaction content of the private transaction, so that even if the private transaction is included in the block to which it belongs and the block is added to the publicly queryable blockchain, unrelated people can only obtain the encrypted transaction content and cannot know the plaintext transaction content. The blockchain node can decrypt the private transaction in the trusted execution environment, obtain the plaintext transaction content, and then execute the plaintext transaction content in the trusted execution environment.
[0049] The transaction initiator can hold the symmetric encryption key and encrypt the transaction content based on the key using symmetric encryption. The private transaction contains the encrypted ciphertext transaction content. Correspondingly, the blockchain node stores the symmetric encryption key in the TEE and decrypts it based on the key using symmetric encryption to obtain the plaintext transaction content.
[0050] Alternatively, the transaction initiator can hold an asymmetric encryption public key and encrypt the transaction content based on the public key using asymmetric encryption. The private transaction contains the encrypted ciphertext transaction content. Accordingly, the blockchain node stores the asymmetric encryption private key in the TEE and decrypts the asymmetric encryption based on the private key to obtain the plaintext transaction content.
[0051] Alternatively, the transaction initiator may hold a symmetric encryption key and an asymmetric encryption public key. The transaction initiator may encrypt the transaction content based on the symmetric encryption key by symmetric encryption, and then encrypt the symmetric encryption key by asymmetric encryption based on the asymmetric encryption public key. The private transaction includes the encrypted ciphertext transaction content and the encrypted key. Accordingly, the blockchain node stores the asymmetric encryption private key in the TEE, and decrypts the encrypted key by asymmetric encryption based on the private key to obtain the symmetric encryption key, and then decrypts the ciphertext transaction content based on the symmetric encryption key by symmetric encryption to obtain the plaintext transaction content. The encryption method used in the above process is digital envelope encryption.
[0052] Corresponding to the privacy transaction using encryption, after the blockchain node decrypts the transaction content in TEE and executes it, it can encrypt the transaction execution result in TEE, and then provide the encrypted transaction execution result to the transaction initiator, and the transaction initiator has the ability to decrypt the encrypted transaction execution result. For example, the blockchain node can encrypt the transaction execution result in TEE using the above-mentioned symmetric encryption key, and the client of the transaction initiator can decrypt it accordingly. For another example, the blockchain node can encrypt the transaction execution result in TEE using an asymmetric encryption public key, and the client of the transaction initiator can decrypt it using the corresponding asymmetric encryption private key. For another example, the blockchain node can encrypt the transaction execution result in TEE using a symmetric encryption key, and encrypt the symmetric encryption key using an asymmetric encryption public key, and the client of the transaction initiator can decrypt the symmetric encryption key using the corresponding asymmetric encryption private key, and then decrypt the transaction execution result based on the key.
[0053] The symmetric encryption key and asymmetric encryption public and private key used in the above encryption and decryption process can be determined by negotiation between the client of the transaction initiator and the blockchain node, or can be issued to the client of the transaction initiator and the blockchain node by the KMS (Key Management Service) server through the TEE on the blockchain node through remote certification. Among them, the encryption algorithm used for symmetric encryption is, for example, DES algorithm, 3DES algorithm, TDEA algorithm, Blowfish algorithm, RC5 algorithm, IDEA algorithm, etc.; the asymmetric encryption algorithm is, for example, RSA, Elgamal, backpack algorithm, Rabin, DH, ECC (elliptic curve encryption algorithm), etc.
[0054] The transactions in this specification can be used to implement relatively simple processing logic, such as transfer logic similar to the related art. At this time, whether it is the above-mentioned plaintext transaction or private transaction, it has nothing to do with the smart contract.
[0055] The transactions in this manual can also be used to implement relatively complex processing logic, which can be achieved with the help of the above-mentioned smart contracts. Taking Ethereum as an example, the core of Ethereum as a programmable blockchain is the Ethereum Virtual Machine (EVM), and each Ethereum node can run EVM. EVM is a Turing-complete virtual machine, which means that various complex logics can be implemented through it. Users publish and call smart contracts in Ethereum to run on EVM. Figure 1 As shown, by deploying EVM in a conventional execution environment, the smart contract for publishing or calling plaintext transactions can be executed through the EVM to realize the "transaction execution" link in the conventional execution environment; and, by deploying EVM in TEE, the smart contract for publishing or calling private transactions can be executed through the EVM to realize the "transaction execution" link in TEE.
[0056] For example Figure 3 As shown in the figure, after Bob sends a transaction containing the information of creating a smart contract to the Ethereum network, the EVM of node 1 can execute this transaction and generate the corresponding contract instance. The data field of the transaction can store the code of the smart contract (such as bytecode), and the to field of the transaction is an empty account. After the nodes reach an agreement through the consensus mechanism, the contract is successfully created, and subsequent users can call this contract. After the contract is created, a contract account corresponding to the smart contract appears on the blockchain, with a specific address, and the contract code and account storage will be saved in the contract account. The behavior of the smart contract is controlled by the contract code, and the account storage of the smart contract saves the state of the contract. In other words, the smart contract generates a virtual account containing the contract code and account storage on the blockchain.
[0057] Furthermore, if Figure 4 As shown in Figure 4, still taking Ethereum as an example, after Bob sends a transaction to call a smart contract to the Ethereum network, the EVM of node 1 can execute this transaction and generate the corresponding contract instance. In Figure 4, the from field of the transaction is the address of the account that initiates the call to the smart contract, the "0x692a70d2..." in the to field represents the address of the smart contract being called, the value field is the value of Ethereum in Ethereum, and the data field of the transaction stores the method and parameters for calling the smart contract. After calling the smart contract, the value of balance may change. Later, a client can view the current value of balance through a blockchain node. Smart contracts can be executed independently on each node in the blockchain network in a prescribed manner, and all execution records and data are saved on the blockchain. Therefore, when such a transaction is completed, the blockchain saves the transaction voucher that cannot be tampered with or lost.
[0058] For the above-mentioned privacy transactions, after the blockchain node decrypts the above-mentioned plaintext transaction content in the TEE, if the plaintext transaction content is related to the smart contract, for example, the plaintext transaction content is used to publish or call the smart contract, then the smart contract can be called the associated smart contract corresponding to the plaintext transaction content. If the plaintext transaction content is used to publish the above-mentioned associated smart contract, then the code of the associated smart contract is included in the plaintext transaction content, such as in the data field of the plaintext transaction content. If the plaintext transaction content is used to call the above-mentioned associated smart contract, then the code of the associated smart contract is located in the database maintained by the blockchain node. Accordingly, the blockchain node can execute the associated smart contract corresponding to the plaintext transaction content in the TEE, that is, execute the code of the above-mentioned associated smart contract in the EVM deployed in the TEE to realize the publication or call of the associated smart contract. Among them, multiple nested structures can be implemented between smart contracts; for example, the code in smart contract 1 calls smart contract 2, and the code in smart contract 2 points to the contract address 3 generated by creating the smart contract code. Therefore, when the private transaction calls the code in smart contract 1, the code in smart contract 2 is directly called and the smart contract code in the contract address 3 is indirectly called. Then the codes of smart contract 1, smart contract 2 and smart contract 3 will all be executed in the EVM deployed in TEE.
[0059] and Figure 4Similar to the contract state balance in the illustrated embodiment, after the associated smart contract is executed by the EVM, one or more contract states may change in value. Accordingly, the blockchain node can encrypt at least one contract state corresponding to the associated smart contract in the TEE, and write the encrypted contract state to the database. The above-mentioned writing to the database generally refers to storage in a storage medium, and more commonly a persistent storage medium, which can be a disk, a floppy disk, or a memory that can recover data after power-on so that it can be stored persistently.
[0060] The blockchain node can use a symmetric encryption key to encrypt the contract state to obtain the encrypted contract state. For example, after the TEE on the blockchain node passes the remote attestation, the KMS server can issue the symmetric encryption key to the blockchain node; or, the key issued by the KMS server can be used as a root key, and the blockchain node can derive the symmetric encryption key based on the root key. For another example, the symmetric encryption key can be obtained by negotiation between the blockchain nodes in the blockchain network. Of course, in addition to the symmetric encryption key, the contract state can also be encrypted with an asymmetric encryption public key, and the blockchain node holds the asymmetric encryption private key for decrypting the encrypted contract state. The key used to encrypt the contract state can be stored in an enclosure within the TEE of the blockchain node to ensure the security of the key.
[0061] Figure 5 This is a schematic diagram of the relationship between the amount of incoming data and the amount of overhead provided by an exemplary embodiment. Assume that the change in the amount of overhead with the amount of incoming data conforms to the function y=f(x), where y is the amount of overhead and x is the amount of incoming data that the blockchain node transfers to the TEE through a single ECall call; Figure 5 As shown in the figure, the function f(x) is a piecewise function: when the amount of input data is [0, 64KB], the value of the overhead y is basically maintained at about 10μs. When the amount of input data is greater than 64KB, the value of the overhead y basically shows a linear increase.
[0062] Therefore, based on the law of value changes of the above function f(x), when a blockchain node needs to pass a private transaction to TEE, it can package as many private transactions as possible into TEE through a single ECall call. Compared with passing in only one or fewer private transactions each time, the number of ECall calls can be reduced, thereby reducing the overhead incurred by the blockchain node when passing in private transactions.
[0063] based on Figure 5The function f(x) shown in the figure, after receiving a transaction, the blockchain node will have multiple processing methods. The following lists several possible situations:
[0064] A blockchain node may receive a private transaction. The blockchain node can calculate the sum of the data volume of the private transaction and the private transactions already in the buffer queue: if the sum of the data volume does not exceed 64KB, the blockchain node will add the private transaction to the buffer queue and continue to wait for other private transactions received later, so that the sum of the data volume of the private transactions batched into the TEE is as close to the 64KB limit as possible, so as to pass as many private transactions as possible into the TEE in a single ECall (within the 64KB of incoming data volume); if the sum of the data volume exceeds 64KB, the blockchain node can pass all the private transactions originally in the buffer queue into the TEE through a single ECall call, clear the buffer queue, and add the above-mentioned private transactions recently received to the cleared buffer queue.
[0065] A blockchain node may receive a plaintext transaction. In order to ensure that all transactions are executed in sequence, the blockchain node immediately passes all the private transactions in the buffer queue to the TEE through a single ECall call without paying attention to whether the sum of the data volume of the private transactions in the buffer queue is close to the 64KB limit, and the blockchain node processes the above plaintext transactions recently received in the regular execution environment.
[0066] In addition, when the transaction frequency on the blockchain network is low, the privacy transactions added by the blockchain node in the buffer queue may need to wait for a long time before forming a privacy transaction with an incoming data volume close to 64KB. Therefore, the blockchain node can record the reception time or addition time (the time when it is added to the buffer queue) of the first privacy transaction in the buffer queue, so that after determining that the waiting time of the first privacy transaction has reached the preset time, regardless of whether the sum of the data volume of the existing privacy transactions in the buffer queue is close to the 64KB limit, all the privacy transactions in the buffer queue should be immediately passed to TEE through a single ECall call to ensure the timeliness of transaction execution.
[0067] Figure 6 is a schematic structural diagram of a device provided by an exemplary embodiment. Figure 6At the hardware level, the device includes a processor 602, an internal bus 604, a network interface 606, a memory 608, and a non-volatile memory 610, and may also include hardware required for other services. The processor 602 reads the corresponding computer program from the non-volatile memory 610 into the memory 608 and then runs it, forming a transaction scheduling device at the logical level. Of course, in addition to the software implementation, one or more embodiments of this specification do not exclude other implementations, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0068] Please refer to Figure 7 In a software implementation, the transaction scheduling device may include:
[0069] A determination unit 701 enables the blockchain node to determine the amount of data of the received privacy transaction;
[0070] The first transmission unit 702 enables the blockchain node to package multiple privacy transactions whose sum of data volume is not greater than a preset threshold and transmit them to the trusted execution environment through a single function call;
[0071] Among them, when the amount of incoming data is not greater than the preset threshold, the first amount of overhead generated by the single function call is independent of the amount of incoming data; when the amount of incoming data is greater than the preset threshold, the second amount of overhead generated by the single function call is greater than the first amount of overhead and is positively correlated with the amount of incoming data.
[0072] Optionally, the first transmission unit 702 is specifically configured to:
[0073] After receiving any private transaction, the blockchain node adds the data volume of the private transaction to the data volume of all private transactions in the buffer queue;
[0074] The blockchain node adds any private transaction to the buffer queue when the added value is not greater than the preset threshold;
[0075] When the added value is greater than the preset threshold, the blockchain node packages all the private transactions in the buffer queue and transmits them to the trusted execution environment, and adds any private transaction to the cleared buffer queue.
[0076] Optionally, also include:
[0077] The recording unit 703 enables the blockchain node to record the waiting time of the first private transaction in the buffer queue;
[0078] The second transmission unit 704 enables the blockchain node to package all the private transactions in the buffer queue and transmit them to the trusted execution environment when the waiting time reaches a preset time.
[0079] Optionally, also include:
[0080] The third transmission unit 705 enables the blockchain node to package all the private transactions in the buffer queue and transmit them to the trusted execution environment when receiving the plaintext transaction;
[0081] The first execution unit 706 enables the blockchain node to execute the plaintext transaction outside the trusted execution environment.
[0082] Optionally, also include:
[0083] The identification unit 707 enables the blockchain node to identify whether the received transaction is a private transaction or a plaintext transaction according to the type field contained in the transaction.
[0084] Optionally, when the amount of incoming data changes, the value of the first overhead amount remains unchanged or remains substantially unchanged.
[0085] Optionally, the preset threshold is no greater than the pre-allocated space size of the enclave page cache on the blockchain node.
[0086] Optionally, the transaction content of the private transaction is encrypted by the transaction initiator; and the device further includes:
[0087] A decryption unit 708 enables the blockchain node to decrypt the private transaction in a trusted execution environment to obtain plaintext transaction content;
[0088] The second execution unit 709 enables the blockchain node to execute the plaintext transaction content in a trusted execution environment.
[0089] Optionally, also include:
[0090] An encryption unit 710 enables the blockchain node to encrypt the transaction execution result in a trusted execution environment;
[0091] The providing unit 711 enables the blockchain node to provide the encrypted transaction execution result to the transaction initiator, and the transaction initiator has the ability to decrypt the encrypted transaction execution result.
[0092] Optional,
[0093] The plaintext transaction content is related to the smart contract; the second execution unit 709 is specifically used to: enable the blockchain node to execute the associated smart contract corresponding to the plaintext transaction content in a trusted execution environment;
[0094] The device also includes: an encryption storage unit 712, which enables the blockchain node to encrypt at least one contract state corresponding to the associated smart contract in a trusted execution environment, and write the obtained encrypted contract state into a database.
[0095] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which may be in the form of a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver, a game console, a tablet computer, a wearable device or a combination of any of these devices.
[0096] In a typical configuration, a computer includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0097] Memory may include non-permanent storage in a computer-readable medium, in the form of 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.
[0098] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. 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, disk storage, quantum memory, graphene-based storage media 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 temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0099] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0100] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0101] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0102] It should be understood that although the terms first, second, third, etc. may be used to describe various information in one or more embodiments of this specification, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0103] The above description is merely a preferred embodiment of one or more embodiments of the present specification and is not intended to limit one or more embodiments of the present specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present specification shall be included in the scope of protection of one or more embodiments of the present specification.
Claims
1. A transaction scheduling method, include: The blockchain node determines the amount of data received for the private transaction; The blockchain node packages multiple privacy transactions whose total data volume is not greater than a preset threshold and transmits them to the trusted execution environment through a single function call; Among them, when the amount of incoming data is not greater than the preset threshold, the first amount of overhead generated by the single function call is independent of the amount of incoming data; when the amount of incoming data is greater than the preset threshold, the second amount of overhead generated by the single function call is greater than the first amount of overhead and is positively correlated with the amount of incoming data.
2. The method according to claim 1, further comprising: include: The blockchain node decrypts the private transaction in the trusted execution environment to obtain the plaintext transaction content, and executes the associated smart contract corresponding to the transaction content in the trusted execution environment; The blockchain node encrypts at least one contract state corresponding to the associated smart contract in a trusted execution environment, and writes the obtained encrypted contract state into a database.
3. The method according to claim 1, further comprising: include: When the type field included in the received transaction has a first value, determining that the received transaction is a plaintext transaction; and when the type field has a second value, determining that the received transaction is a private transaction; and / or, if the received transaction includes an encryption identifier, determining that the received transaction is a private transaction, otherwise determining that the received transaction is a plaintext transaction; And / or, if the smart contract called by the received transaction contains a privacy identifier or the code of the smart contract includes a contract state marked with a privacy identifier, the received transaction is determined to be a private transaction, otherwise the received transaction is determined to be a plaintext transaction.
4. According to the method of claim 1, the blockchain node packages multiple privacy transactions whose sum of data volume is not greater than a preset threshold into a trusted execution environment through a single function call, include: After receiving any private transaction, the blockchain node adds the data volume of the private transaction to the data volume of all private transactions in the buffer queue; When the added value is not greater than the preset threshold, the blockchain node adds any private transaction to the buffer queue; When the added value is greater than the preset threshold, the blockchain node packages all the private transactions in the buffer queue and transmits them to the trusted execution environment, and adds any private transaction to the cleared buffer queue.
5. The method according to claim 1, further comprising: include: The blockchain node records the waiting time of the first privacy transaction in the buffer queue; When the waiting time reaches a preset time, the blockchain node packages all the private transactions in the buffer queue and transmits them to the trusted execution environment.
6. The method according to claim 1, further comprising: include: When receiving a plaintext transaction, the blockchain node packages all the private transactions in the buffer queue and transmits them to the trusted execution environment; The blockchain node executes the plaintext transaction outside of a trusted execution environment.
7. According to the method of claim 1, when the amount of incoming data changes, the value of the first overhead amount remains unchanged or substantially unchanged.
8. The method of claim 1, wherein the preset threshold is no greater than the pre-allocated space size of the enclave page cache on the blockchain node.
9. The method according to claim 1, further comprising: include: The blockchain node encrypts the transaction execution result in a trusted execution environment; The blockchain node provides the encrypted transaction execution result to the transaction initiator, and the transaction initiator has the ability to decrypt the encrypted transaction execution result.
10. According to the method of claim 1, the blockchain node packages multiple privacy transactions whose sum of data volume is not greater than a preset threshold into a trusted execution environment through a single function call, include: The blockchain node packages the multiple privacy transactions and transmits them to the trusted execution environment through a single ECall function call.
11. A transaction scheduling device, include: A determination unit, which enables the blockchain node to determine the amount of data of the received private transaction; The transmission unit enables the blockchain node to package and transmit multiple privacy transactions whose sum of data volume is not greater than a preset threshold to a trusted execution environment through a single function call; wherein, when the amount of incoming data is not greater than the preset threshold, the first amount of overhead generated by the single function call is independent of the amount of incoming data, and when the amount of incoming data is greater than the preset threshold, the second amount of overhead generated by the single function call is greater than the first amount of overhead and is positively correlated with the amount of incoming data.
12. An electronic device, include: processor; a memory for storing processor-executable instructions; The processor implements the method according to any one of claims 1 to 10 by running the executable instructions.
13. A computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the steps of the method according to any one of claims 1 to 10.
