Transaction execution method, blockchain node, computing device and host thereof

By caching variable states locally in computing devices within blockchain nodes, the method enhances transaction execution efficiency and reduces host communication, addressing inefficiencies in existing blockchain node systems.

CN113836236BActive Publication Date: 2025-01-03ANT BLOCKCHAIN TECHNOLOGY (SHANGHAI) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111155586.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-29
Publication Date
2025-01-03
Estimated Expiration
2041-09-29

AI Technical Summary

Technical Problem

Existing blockchain nodes face inefficiencies in transaction execution due to the lack of shared memory between computing devices, leading to increased communication with the host and reduced transaction speed, especially when dealing with read-only variables.

Method used

Implementing a transaction execution method where computing devices cache variable states locally, allowing them to execute transactions based on cached information and reducing reliance on host communication, particularly for frequently read-only variables.

Benefits of technology

This approach reduces transaction execution time and improves system performance by minimizing communication with the host and ensuring accurate execution results through local caching of variable states.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113836236B_ABST
    Figure CN113836236B_ABST
Patent Text Reader

Abstract

An embodiment of the present specification provides a blockchain node, a computing device and a host included in the blockchain node, and a transaction execution scheme, wherein the host is configured to send part of the transactions in a first block to the computing device and receive the execution result of the transaction from the computing device, the host includes a first storage space, the first storage space is used to store multiple first information of the first block during the execution of the first block, the multiple first information respectively indicate the current status of multiple variables accessed during the execution; the computing device is configured to receive the part of the transaction from the host, execute the part of the transaction, and send the execution result of the transaction and the second information to the host, the computing device includes a second storage space, the second storage space is used to store the status of the variables accessed during the execution of the part of the transaction, and the second information indicates the status of the variables read during the execution.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of this specification relate to the field of blockchain technology, and more specifically, to a method for executing transactions in a blockchain node, a blockchain node, and a computing device and a host in the blockchain node. Background Art

[0002] Blockchain is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithm. In the blockchain system, data blocks are combined into a chain data structure in a sequential manner according to time order, and cryptography is used to ensure that data blocks cannot be tampered with or forged. When executing multiple transactions in a block, blockchain nodes can speed up transaction execution by executing transactions in parallel.

[0003] In some blockchain nodes, transactions in a block can be executed in parallel by at least two computing devices. Each computing device includes its own processor and memory, and the computing devices do not share memory. In this scenario, the computing device side usually obtains the required status information by accessing the host when executing a transaction. Summary of the invention

[0004] The embodiments of this specification are intended to provide a transaction execution solution to reduce transaction execution time and improve the system efficiency of blockchain nodes.

[0005] A first aspect of the present specification provides a transaction execution method, the method being executed by a blockchain node, the blockchain node comprising a host and a first computing device, the method comprising:

[0006] The host sends part of the transactions in the first block to the first computing device, wherein the part of the transactions includes a first transaction, the first transaction includes a read operation on a first variable, the host includes a first storage space, the first storage space is used to store a plurality of first information of the first block during the execution of the first block, the plurality of first information respectively indicating current states of a plurality of variables accessed during the execution, and the first computing device includes a second storage space;

[0007] After the first computing device starts to execute the first transaction, at least when it is determined that the first state of the first variable is stored in the second storage space, the first computing device reads the first state of the first variable from the second storage space, obtains an execution result of the first transaction according to the first state, and sends the execution result and second information to the host, wherein the second information indicates that the first state is read during the execution of the first transaction;

[0008] After sequentially submitting transactions in the first block whose submission order is before the first transaction, the host submits the first transaction when determining that the first state is the current state of the first variable according to the first information and the second information.

[0009] In one embodiment, the method further includes: after the host sequentially submits transactions in the first block whose submission order is before the first transaction, and when it is determined based on the first information and the second information that the first state is not the current state of the first variable, notifying the first computing device to re-execute the first transaction.

[0010] In one embodiment, the method also includes: before executing the first transaction, the first computing device sends a read request for the first variable corresponding to a second transaction to the host; the host sends the current first state of the first variable and an identifier of a third transaction to the first computing device in response to the read request of the first computing device, and the third transaction is a transaction for writing the first state; the first computing device records the first state information of the first variable in the second storage space, the first state information includes the first state and the identifier of the third transaction, and the second information is the identifier of the third transaction.

[0011] In one embodiment, the method also includes, after the host sends the first state of the first variable and the identifier of the third transaction to the first computing device, recording first execution information corresponding to the first variable and the first computing device in the first storage space, the first execution information including the second transaction and the third transaction, indicating that the state written by the third transaction was read during the execution of the second transaction.

[0012] In one embodiment, the method further includes, after receiving the execution result and the second information, the host records second execution information corresponding to the first variable and the first computing device in the first storage space, the second execution information including the first transaction and the third transaction.

[0013] In one embodiment, the first information of the first variable is an identifier of a transaction that writes the current state of the first variable, and determining the first state as the current state of the first variable based on the first information and the second information includes, when the first information of the first variable is an identifier of the third transaction, determining the first state as the current state of the first variable.

[0014] In one embodiment, the method further comprises: the host sending the submission order of the partial transactions to the first computing device;

[0015] The reading of the first state of the first variable comprises: reading the first state when it is determined that the first state information of the first variable is stored in the second storage space and the submission order of the third transaction is before the first transaction.

[0016] In one embodiment, the method further includes: after the first computing device stores the first state information in the second storage space, upon determining that the second storage space stores information indicating that the first transaction read the state of the first variable written by the fourth transaction, re-executing the first transaction.

[0017] In one embodiment, the method further includes, when the first computing device determines that the second storage space does not store the reading information of the first variable by the first transaction, recording in the second storage space information that the first transaction reads the state of the first variable written by the third transaction, and after obtaining the execution result of the first transaction, the first computing device obtains the second information from the second storage space.

[0018] In one embodiment, the first transaction also includes a write operation on a second variable, and the method also includes: after the first computing device executes the write operation, recording second state information of the second variable in the second storage space, the second state information including an identifier of the first transaction and a second state of the second variable written by the first transaction.

[0019] In one embodiment, the method further includes: after the host submits the first transaction, recording the current state of the second variable as the second state, and recording the first transaction as a transaction for writing the second state of the second variable.

[0020] In one embodiment, the first storage space stores third execution information corresponding to the second variable and the second computing device, the third execution information includes a fifth transaction and a sixth transaction, indicating that the state of the second variable written by the sixth transaction is read during the execution of the fifth transaction, the submission order of the fifth transaction is after the first transaction, and the submission order of the sixth transaction is before the first transaction, and the method further includes: the host notifies the second computing device to re-execute the fifth transaction according to the third execution information after receiving the execution result, after submitting the first transaction, or before submitting the fifth transaction.

[0021] In one implementation, the first computing device is a computing unit included in an FPGA chip.

[0022] A second aspect of the present specification provides a transaction execution method, the method being executed by a computing device included in a blockchain node, the blockchain node also including a host, the method comprising:

[0023] Receiving a portion of transactions in a first block from a host, wherein the portion of transactions includes a first transaction, and the first transaction includes a read operation on a first variable;

[0024] After starting to execute the first transaction, at least in the case of determining that a first state of the first variable is stored in a storage space of the computing device, reading the first state of the first variable from the storage space, and obtaining an execution result of the first transaction according to the first state;

[0025] The execution result and second information are sent to the host, wherein the second information indicates that the first status is read during the execution of the first transaction.

[0026] In one embodiment, the method further includes, before executing the first transaction, sending a read request for the first variable corresponding to a second transaction to the host; receiving a current first state of the first variable and an identifier of a third transaction from the host, the third transaction being a transaction for writing the first state; and recording first state information of the first variable in the storage space, the first state information including the first state and an identifier of the third transaction, wherein the second information is an identifier of the third transaction.

[0027] In one embodiment, the method also includes receiving a submission order of the partial transactions from a host, and reading the first state of the first variable at least in a case where it is determined that the first state of the first variable is stored in the storage space includes: reading the first state in a case where it is determined that the first state information of the first variable is stored in the storage space and the submission order of the third transaction is before the first transaction.

[0028] In one embodiment, the method further includes: after storing the first state information of the first variable in the storage space, in a case where it is determined that the storage space stores information that the first transaction read the state value of the first variable written by the fourth transaction, re-executing the first transaction.

[0029] In one embodiment, the method further includes, in a case where it is determined that the storage space does not store the read information of the first variable by the first transaction, recording in the storage space information that the first transaction reads the state value of the first variable written by the third transaction, and after obtaining the execution result of the first transaction, obtaining the second information from the storage space.

[0030] In one embodiment, the first transaction also includes a write operation on a second variable, and the method further includes: after executing the write operation, recording second state information of the second variable in the storage space, the second state information including an identifier of the first transaction and a second state of the second variable written by the first transaction.

[0031] A third aspect of the present specification provides a transaction execution method, the method being executed by a host included in a blockchain node, the blockchain node also including a computing device, the method comprising:

[0032] Sending part of the transactions in the first block to the computing device, wherein the part of the transactions includes a first transaction, the first transaction includes a read operation on a first variable, the host includes a first storage space, the first storage space is used to store a plurality of first information of the first block during the execution of the first block, the plurality of first information respectively indicating current states of a plurality of variables accessed during the execution, and the computing device includes a second storage space;

[0033] receiving, from the computing device, an execution result of the first transaction and second information, wherein the second information indicates that a first state of a first variable stored in the second storage space is read during execution of the first transaction;

[0034] After sequentially submitting transactions in the first block whose submission order is before the first transaction, and when it is determined that the first state is the current state of the first variable according to the first information and the second information, the first transaction is submitted.

[0035] A fourth aspect of this specification provides a blockchain node, including a host and a computing device,

[0036] The host is configured to send part of the transactions in the first block to the computing device and receive the execution result of the transactions from the computing device, and the host includes a first storage space, the first storage space is used to store a plurality of first information of the first block during the execution of the first block, the plurality of first information respectively indicating the current status of a plurality of variables accessed during the execution;

[0037] The computing device is configured to receive the partial transaction from the host, execute the partial transaction, and send the execution result of the transaction and the second information to the host. The computing device includes a second storage space, and the second storage space is used to store the state of the variables accessed during the execution of the partial transaction. The second information indicates the state of the variables read during the execution process.

[0038] In one implementation, the first information is an identifier of a transaction written into the current state, and the second storage space is further used to store an identifier of a second transaction corresponding to the first state of the first variable read by the first transaction in the partial transaction, the second transaction is a transaction written into the first state, and the second information is an identifier of the second transaction.

[0039] The host is further configured to determine whether the first transaction is successfully executed based on the identifier of the second transaction and the first information of the first variable.

[0040] In one embodiment, the host is also configured to record execution information corresponding to the first variable and the first computing device in the first storage space after receiving the execution result and the second information, the execution information including the first transaction and the second transaction, indicating that the status written by the second transaction was read during the execution of the first transaction.

[0041] In a fifth aspect, the present specification provides a computing device for a blockchain node, wherein the blockchain node further includes a host, and the computing device includes:

[0042] A receiving unit, configured to receive a portion of transactions in a first block from a host, wherein the portion of transactions includes a first transaction, and the first transaction includes a read operation on a first variable;

[0043] a reading unit, configured to, after starting to execute the first transaction, read the first state of the first variable from the storage space at least when it is determined that the first state of the first variable is stored in the storage space, and obtain an execution result of the first transaction according to the first state;

[0044] A sending unit is used to send the execution result and second information to the host, where the second information indicates that the first status is read during the execution of the first transaction.

[0045] A sixth aspect of the present specification provides a host for a blockchain node, wherein the blockchain node also includes a computing device, and the host includes:

[0046] a sending unit, configured to send part of the transactions in the first block to the computing device, wherein the part of the transactions includes a first transaction, the first transaction includes a read operation on a first variable, the host includes a first storage space, the first storage space is used to store a plurality of first information of the first block during the execution of the first block, the plurality of first information respectively indicating current states of a plurality of variables accessed during the execution, and the computing device includes a second storage space;

[0047] a receiving unit, configured to receive an execution result of the first transaction and second information from the computing device, wherein the second information indicates that a first state of a first variable stored in the second storage space is read during execution of the first transaction;

[0048] A submitting unit is used to submit the first transaction after sequentially submitting transactions in the first block whose submission order is before the first transaction, and when it is determined according to the global execution information that the first state is the current state of the first variable, submit the first transaction.

[0049] A seventh aspect of the present specification provides a computing device, including 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 of the present specification is implemented.

[0050] The eighth aspect of the present 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 fourth aspect of the present specification.

[0051] Through the transaction execution solution provided in the embodiments of this specification, the states of variables accessed during the transaction execution process are cached separately in multiple computing devices that do not share memory in the blockchain node. For variables that are frequently read-only, the state values ​​of the variables cached in the computing devices are correct state values, so that the computing devices can read the correct state values ​​of the variables directly from the local memory without going through the host, thereby reducing the communication time with the host, reducing the transaction execution time, and improving system performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] The embodiments of this specification are described in conjunction with the accompanying drawings to make the embodiments of this specification clearer:

[0053] Figure 1 An architectural diagram of a blockchain node provided in an embodiment of this specification is shown;

[0054] Figure 2 A flowchart of a transaction execution method provided in an embodiment of this specification;

[0055] Figure 3A schematic diagram of a buffer zone in a computing device provided in an embodiment of the present specification;

[0056] Figure 4 A schematic diagram of a global buffer of a host provided in an embodiment of this specification;

[0057] Figure 5 A flow chart of a method for writing a variable in a blockchain node provided in an embodiment of this specification;

[0058] Figure 6 An architectural diagram of a computing device for a blockchain node provided in an embodiment of this specification;

[0059] Figure 7 An architectural diagram of a host for a blockchain node provided in an embodiment of this specification. DETAILED DESCRIPTION

[0060] The embodiments of this specification will be described below with reference to the accompanying drawings.

[0061] Figure 1 The following is an architecture diagram of a blockchain node provided in an embodiment of this specification. Figure 1 As shown, the blockchain node includes a host 100, a computing device 210 and a computing device 220. The host 100 includes a processor 101 and a memory 102, and the memory 102 can store the global information of the computing device 210 and the computing device 220 in the process of executing the block. The host 100 can be used to perform the following operations: receive transactions from the client or other blockchain nodes, determine multiple transactions in the block and the submission order of the multiple transactions through consensus, send multiple transactions in the block to the computing device 210 and the computing device 220 respectively, coordinate the parallel execution of the transaction by the computing device 210 and the computing device 220, and perform operations such as generating blocks and updating the world state after the transaction execution is completed.

[0062] The computing device 210 and the computing device 220 are used to execute transactions in parallel. The computing device 210 and the computing device 220 can be two spatially separated devices, for example, they can be two computers communicating with the host, or they can be two computing chips plugged into the host, etc. Alternatively, the computing device 210 and the computing device 220 can also be two sub-devices included in an integral device, for example, they can be two sub-devices (such as computing units) in an FPGA chip plugged into the host. Among them, the computing device 210 includes a processor 211 and a memory 212, and the memory 212 is used to store the state information of the variables obtained during the execution of the transaction by the processor 211, and the computing device 220 includes a processor 221 and a memory 222, and the memory 222 is used to store the state information of the variables obtained during the execution of the transaction by the processor 221. Whether the computing device 210 and the computing device 220 are spatially separated or integrated into one device, they have their own memory space, and the memory 212 is separated from the memory 222, that is, the computing device 210 and the computing device 220 do not share memory.

[0063] Understandably, Figure 1 Although only two computing devices are shown as examples, this is not intended to limit the scope of the embodiments of this specification. In one embodiment, the blockchain node may include only a host 100 and a computing device, and the host and the computing device execute transactions in parallel. The computing device is, for example, a computer that communicates with the host, or a computing chip installed on the host. In another embodiment, the blockchain node may include a host 100 and two or more (for example, three) computing devices, and the multiple computing devices may execute multiple transactions in a block in parallel. In addition, Figure 1 Although it is shown that the host 100 stores global information through the memory 102, and the computing devices 210 and 220 store state information through their respective memories, the embodiments of this specification are not limited thereto, and other storage media may be used to store information.

[0064] In the related art, when computing device 210 and computing device 220 execute multiple transactions in a block in parallel, they will not store state information in their respective memories. This is because computing device 210 and computing device 220 are both executing transactions in parallel, and they may change the state of the same variable. There is no communication between computing device 210 and computing device 220, for example, computing device 210 cannot obtain the state information of the transaction execution process in computing device 220. Therefore, even if computing device 210 stores the state information obtained in the local transaction execution process, the state information may be wrong for a specific transaction, and executing the transaction based on the state information will cause the transaction execution to fail. The usual practice is that when each transaction is executed, computing device 210 obtains the state information from host 100 when it needs to read the state information, and executes the transaction based on the obtained state information. After executing the transaction, computing device 210 sends the execution result of the transaction to the host, and host 100 determines whether the transaction is successfully executed based on the cached information, and submits the transaction in the case of successful execution.

[0065] In the above-mentioned related technologies, since data cache is not enabled in the computing device, all data access requests must be sent to the host 100, which increases the number of communications between the computing device and the host, reduces the transaction execution speed, and limits the system performance.

[0066] The embodiments of the present specification provide a transaction execution scheme, wherein a computing device stores status information of variables in a local memory. When executing a transaction, the computing device directly executes the transaction based on the locally cached status information, and sends the execution result of the transaction and the read status information to a host. The host side determines whether the execution of the transaction is successful through the stored global information, thereby improving the transaction execution speed, especially in scenarios where most of the variables read in the transaction are read-only variables.

[0067] Figure 2 This is a flow chart of the transaction execution method provided in the embodiment of this specification. Figure 2 The computing device shown may be Figure 1 The computing device 210 or the computing device 220 in the embodiment, the computing device 210 is taken as an example for description below. Figure 2 The method flow shown is a flow in which a transaction performed by a computing device includes a read operation on a variable. Figure 2 The steps shown.

[0068] First, in step S201 , the host 100 sends a portion of transactions of block B1 to the computing device 210 .

[0069] The host 100 reaches a consensus with the hosts of other nodes in the blockchain to determine the multiple transactions included in the block to be executed (e.g., block B1) and the submission order of the multiple transactions. After determining the multiple transactions in block B1, the host 100 can divide the multiple transactions into two groups of transactions, and send the two groups of transactions to the computing device 210 and the computing device 220 respectively, so that the computing device 210 and the computing device 220 can execute the two groups of transactions in parallel. Specifically, the host 100 can randomly divide the multiple transactions into two groups of transactions, or can divide the multiple transactions into two groups of transactions according to a preset rule. For example, a group of transactions sent by the host 100 to the computing device 210 includes odd-numbered transactions such as transaction Tx1, transaction Tx3, transaction Tx5, and transaction Tx7, and a group of transactions sent by the host 100 to the computing device 220 includes even-numbered transactions such as transaction Tx2, transaction Tx4, transaction Tx6, and transaction Tx8.

[0070] In step S203 , the computing device 210 determines whether the buffer hits the variable Key1 to be read in the transaction Txi (described below using Tx1 and Tx3 as examples).

[0071] After receiving, for example, transaction Tx1, transaction Tx3, transaction Tx5, and transaction Tx7, the computing device 210 may execute the four transactions in parallel or in series.

[0072] Figure 3 Schematic diagram showing a buffer in the memory 212 of the computing device 210. Figure 3 As shown, the memory 212 may include buffer 1, buffer 2 and buffer 3. Buffer 1 is used to store the status value of each variable to provide the status value of the variable when the computing device 210 executes a transaction. After the computing device 210 obtains the status value of the variable from the host during the execution of the transaction, or writes the status value of the variable during the execution of the transaction, the computing device 210 stores the status value of the variable in buffer 1. Buffer 2 is, for example, a private buffer corresponding to transaction Tx3. After the computing device 210 reads the status value V0 of the variable Key1 during the execution of transaction Tx3, for example, buffer 2 is established, and the status information of the variable Key1 read by transaction Tx3 is stored in buffer 2. Buffer 3 is, for example, a private buffer corresponding to transaction Tx5, and can be established similarly to buffer 2. It can be understood that the memory 212 may also include other buffers corresponding to other transactions. Figure 3 Not shown in FIG.

[0073] Specifically, the information of variable Key1 in buffer 1 includes "Tx-1, V0", indicating that the state value V0 of Key1 is the state value corresponding to the previous block of block B1. The information of variable Key1 in buffer 1 also includes "Tx3, V13", indicating that the state value V13 of Key1 is written when transaction Tx3 is executed. In other words, Tx-1 and Tx3 recorded in buffer 1 are used to indicate the transaction number in which the state value of variable Key1 is written. "Key1, Tx-1" is included in buffer 2, indicating that the state value of variable Key1 corresponding to transaction Tx-1 is read when transaction Tx3 is executed.

[0074] Understandably, Figure 3 The specific contents in each buffer shown are only exemplary and are not intended to limit the scope of the embodiments of this specification. When the computing device 210 executes multiple transactions in parallel, by recording the numbers of the write transactions corresponding to each state value of the variable in the buffer 1, it is helpful to read the state value corresponding to the current transaction when executing the read operation in the transaction. When the computing device 210 executes multiple transactions in series in the order of transaction numbers from small to large, for example, serially executing transactions Tx1, Tx3, Tx5 and Tx7, only the latest state value of the variable can be recorded in the buffer 1, so that when executing the read operation in the transaction, the latest state value can be read to continue executing the current transaction. In addition, the buffer 2 is not limited to recording the transaction number corresponding to the variable value read in the transaction Tx3, but can record other information used to determine the variable value, for example, the version number information of the state value V0 of the variable can be recorded in the buffer 2. By storing information indicating the state of the variables read during the execution of the transaction in the private buffer of the transaction (e.g., buffer 2 corresponding to transaction Tx3), the computing device can read the information from the private buffer when executing the transaction and sending the execution result to the host, and send the information and the execution result to the host, so that the host can determine whether the transaction needs to be re-executed based on the information (this part will be described in detail in the subsequent steps). In addition, the computing device can also determine whether the transaction needs to be re-executed based on the information in the private buffer of the transaction (this part will be described in detail below).

[0075] Assume that the computing device 210 first executes transaction Tx1, which includes a read operation on variable Key1. After executing the read operation in transaction Tx1, the computing device 210 first determines whether the variable Key1 can be hit in buffer 1 in the memory, that is, determines whether the state information of Key1 is stored in buffer 1.

[0076] In the case where it is determined that the state information of Key1 is not stored in buffer 1, the computing device 210 executes step S205 to send a state read request to the host 100 to read the current state (ie, the latest state) of the variable Key1.

[0077] In step S207 , the host 100 reads the current state of the variable Key1 in response to the read request of the computing device 210 .

[0078] A global buffer corresponding to the execution block B1 is set in the memory 102 of the host 100 . Figure 4 A schematic diagram of a global buffer is shown. In one embodiment, the global buffer may store the current state of each variable ( Figure 4 ). Specifically, after the host 100 reads the state of any variable from the state database in response to a read request from any computing device during the execution of block B, the read state can be stored in the global buffer as the current state of the variable in association with the variable, or, when the host determines that the transaction of writing any variable in block B1 is successfully executed and submits the transaction, the state of the variable written by the transaction can be stored in the global buffer as the current state of the variable in association with the variable. Taking variable Key1 as an example, after receiving the read request for variable Key1 sent by computing device 210 when executing transaction Tx1, host 100 will first determine whether variable Key1 is hit in the global buffer. If there is no hit, it means that no transaction has accessed variable Key1 at present. Therefore, host 100 reads the state value V0 of variable Key1 (i.e., the current state of variable Key1) from the state database and stores the current state V0 of variable Key1 in the global buffer.

[0079] In another embodiment, if Figure 4 As shown, in addition to storing the current state of the variable in the global buffer, the transaction number corresponding to the current state can also be stored. The transaction number corresponding to the current state is also the number of the transaction written into the current state. For example, the current state of the variable Key1 read above is the state V0 of the variable Key1 corresponding to the previous block of block B1, so the transaction number corresponding to the state V0 can be recorded as Tx-1.

[0080] In another embodiment, if Figure 4As shown, in addition to storing the current state of the variable and the identifier of the related transaction, the global buffer can also store the state information of the variable read by the transaction of reading the variable respectively executed by the computing device 210 and the computing device 220. In this embodiment, after the host 100 reads the state V0 of the variable Key1 from the state database in response to the above read request, it can execute step S209 to add a record "Tx1, Tx-1" associated with the variable Key1 and the computing device 210 in the global buffer to indicate that the state value (i.e., V0) of the variable Key1 corresponding to the transaction Tx-1 was read during the execution of the transaction Tx1. By recording this information, it can be determined whether the transaction needs to be re-executed before submitting the transaction.

[0081] In step S211 , the host 100 returns the current state V0 of the variable Key1 to the computing device 210 .

[0082] In one implementation, the host 100 may only return the status V0 to the computing device 210 .

[0083] In another embodiment, the host 100 may return the status V0 and the corresponding transaction number Tx-1 to the computing device 210 .

[0084] In step S213 , the computing device 210 updates the buffer 1 and the private buffer corresponding to the transaction Tx1 .

[0085] In one implementation, the computing device 210 may store only the state value “ V0 ” in association with the variable Key1 in the buffer 1 to indicate the current state of the variable Key1 .

[0086] In another embodiment, if Figure 3 As shown, computing device 210 may store “Tx-1, V0” in association with variable Key in buffer 1. Computing device 210 may also store “Key1, Tx-1” ( Figure 3 not shown).

[0087] In step S215, the computing device 210 continues to execute the transaction Tx1 based on the state V0, and obtains the execution result of the transaction Tx1. The computing device 210 generates a read set and a write set in the process of executing the transaction Tx1, wherein the read set includes the state values ​​of each variable read in the process of executing the transaction, and the write set includes the state values ​​of each variable written in the process of executing the transaction. The execution result includes, for example, a write set generated in the process of executing the transaction Tx1.

[0088] In step S217 , the computing device 210 sends the execution result of the transaction Tx1 and information indicating the status of the reading of the transaction Tx1 to the host 100 .

[0089] In one embodiment, the computing device 210 may obtain the state value V0 of the variable Key1 read during the execution of the transaction Tx1 from the read set of the transaction Tx1, and send the execution result of the transaction Tx1 and the state value V0 to the host 100.

[0090] In another embodiment, the computing device 210 can read the transaction number "Tx-1" corresponding to the state value (V0) of the variable key1 read during the execution of transaction Tx1 from the private cache area corresponding to the transaction Tx1, and send the execution result of transaction Tx1 and the transaction number "Tx-1" to the host 100.

[0091] Optionally, after receiving the execution result and the information indicating the status of transaction Tx1, the host 100 executes step S219 to record the status information of each variable read by transaction Tx1 in the global buffer. Here, since the host 100 has previously recorded "Tx1 Tx-1" in the global buffer in association with the variable Key1 and the computing device 210, there is no need to store it repeatedly. If the status of other variables stored in the computing device 210 is also read during the execution of transaction Tx1, the information of the read status can be similarly recorded in the global buffer in association with the computing device 210 and the other variables. By making this record, before submitting transaction Tx1, it can be determined whether transaction Tx1 has read an incorrect status based on the record, so as to determine whether to re-execute transaction Tx1.

[0092] In step S221, the host 100 determines whether the transaction Tx1 is successfully executed.

[0093] In one embodiment, the computing device 210 sends the execution result of the transaction Tx1 and the state value V0 of the variable key1 to the host 100, and the global buffer records the current state of the variable Key1 as V0. Thus, the host 100 can determine that the state of the variable Key1 read by the transaction Tx1 is correct by comparing the state value V0 included in the execution result and the state value V0 recorded in the global buffer. Therefore, it can be determined that the transaction Tx1 is successfully executed.

[0094] In another embodiment, the computing device 210 sends the execution result of the transaction Tx1 and the transaction number "Tx-1" corresponding to the state value V0 read from the private buffer of the transaction Tx1 to the host 100, and the transaction related to the current state V0 of the variable Key1 recorded in the global buffer is the transaction Tx-1. Thus, the host 100 can determine that the state of the variable Key1 read by the transaction Tx1 is the correct one based on the transaction number "Tx-1" corresponding to the received state value V0 and the transaction number "Tx-1" associated with the current state value of the variable Key1 recorded in the global buffer, and thus can determine that the transaction Tx1 is successfully executed.

[0095] In step S225 , after determining that the transaction Tx1 is successfully executed, the host 100 may submit the transaction Tx1 .

[0096] Specifically, the host 100 can update the variable status information in the global buffer according to the execution result of the transaction Tx1, and put the execution result of the transaction Tx1 into the data set of the submitted transaction. Specifically, if the transaction Tx1 also includes a write operation on any variable (for example, the variable Key2) (for example, the status value of the variable Key2 written is V21), the host 100 can record in the global buffer that the current status of the variable Key2 is V21, and the related transaction is transaction Tx1. In addition, the host 100 can also delete the aforementioned record of the read information of the status of the variable Key1 by the transaction Tx1 in the global buffer (for example, "Tx1 Tx-1"). Figure 4 The dotted box in FIG. 1 represents the deletion of the information ("Tx1 Tx-1").

[0097] Going back to step S203, it is assumed that the transaction Tx3 to be executed by the computing device 210 also includes a read operation on the variable Key1. Assuming that the computing device 210 executes the read operation in the transaction Tx3 after submitting the transaction Tx1, the computing device 210 determines whether the variable Key1 to be read in the transaction Tx3 is hit in the buffer 1 after executing the read operation in the transaction Tx3. At this time, since the transaction Tx1 for reading the variable Key1 has been executed before, Key1 can be hit in the buffer 1, so that the computing device 210 can directly read the state value V0 of the variable Key1 from the buffer 1, and execute step S215, continue to execute the transaction Tx3 based on the state value V0 of the variable Key1 read from the buffer 1, and obtain the execution result of the transaction Tx3.

[0098] In one embodiment, the computing device 210 executes transactions Tx1, Tx3, Tx5, etc. in the order of transaction numbers from small to large, and only records the latest state of the variable Key1 obtained by the computing device 210 in the buffer 1. Therefore, the computing device 210 can read the state value of the variable Key1 from the buffer 1 when executing the read operation in the transaction Tx3. In this embodiment, the transaction number corresponding to the state value of the variable Key1 can also be recorded in the buffer 1. After reading the state value, the computing device 210 can also store the transaction number corresponding to the state value (for example, transaction Tx-1) in association with the variable Key1 in the private buffer corresponding to the transaction Tx3 (for example, Figure 3 in the buffer 2).

[0099] In another embodiment, the computing device 210 executes transactions Tx1, Tx3, and Tx5 in parallel. The computing device 210 may record multiple state values ​​of each variable and the transaction number corresponding to each state value in the buffer 1 (e.g., Figure 3 ). Figure 3 As shown, it is assumed that the entry of variable Key1 in buffer 1 currently records "Tx-1, V0" and "Tx5, V15" (currently ignored Figure 3 ), since the transaction number of transaction Tx3 (i.e., 3) is less than the transaction number of transaction Tx5 (i.e., 5) and greater than the transaction number of transaction Tx-1, the computing device 210 reads the state value "V0" before the execution of transaction Tx3 from buffer 1, and continues to execute transaction Tx3 based on "V0". Similarly, after reading the state value "V0", the computing device 210 may record "Key1, Tx-1" in the buffer 2 corresponding to transaction Tx3 to indicate that the state value V0 corresponding to transaction Tx-1 was read during the execution of transaction Tx3.

[0100] After executing and completing transaction Tx3, the computing device 210 executes step S217, and sends the execution result of transaction Tx3 and information indicating the status of transaction Tx3 reading to the host 100. Similar to the above, the status information indicating the status of transaction Tx3 reading may be the status value V0, or may be the transaction number "Tx-1" corresponding to the status value V0.

[0101] Optionally, after receiving the execution result and status information of transaction Tx3, host 100 executes step S219 to record the reading of status value V0 of variable key1 by transaction Tx3 in the global buffer, for example, Figure 4As shown, the host 100 may record "Tx3 Tx-1" in the global buffer corresponding to the variable Key1 and the computing device 210 to indicate that the transaction Tx3 reads the state of the variable Key1 written by the transaction Tx-1. By making this record, before submitting the transaction Tx3, if the transaction submitted before the transaction Tx3 writes to the variable Key1, it can be determined based on the record whether the transaction Tx3 reads the wrong state, and thus it can be determined whether to re-execute the transaction Tx3.

[0102] Afterwards, the host 10 executes step S221 to determine whether the transaction Tx3 is successfully executed.

[0103] Specifically, the host 100 submits each transaction in the order of transaction numbers from small to large, that is, after submitting transaction Tx2, the submission of transaction Tx3 begins. When submitting transaction Tx3, the host 100 determines whether transaction Tx3 reads an outdated state value based on the current state information of variable Key1 recorded in the global buffer and the information indicating the state of transaction Tx3, thereby determining whether transaction Tx3 is successfully executed.

[0104] In one embodiment, the computing device 210 sends the state value V0 read from the transaction Tx3 obtained from the read set of the transaction Tx3 together with the execution result of the transaction Tx3 to the host 100, assuming that the current state value of the variable Key1 is recorded in the global buffer as V12. The host 100 can determine that the value "V0" of the variable Key1 read during the execution of the transaction Tx3 is inconsistent with the current state value of the variable Key1, and therefore, the host 100 can determine that the execution of the transaction Tx3 has failed.

[0105] In another embodiment, the computing device 210 sends the transaction number "Tx-1" corresponding to the state value V0 together with the execution result of the transaction Tx3 to the host 100. Assume that the transaction number of the current state of the variable Key1 written in the current global buffer in the host 100 is transaction TX2. The host 100 can determine that the transaction "Tx-1" related to the state value of the variable Key1 read in the transaction Tx3 is inconsistent with the transaction "Tx2" related to the current state of the variable Key1, and therefore, the host 100 can determine that the execution of the transaction Tx3 failed. Optionally, when the host 100 records "Tx3 Tx-1" in the global buffer after receiving the execution result and the information indicating the state of the transaction Tx3 as described above, the host 100 can obtain the transaction "Tx-1" related to the state value of key1 read by the transaction Tx3 from the record, and judge that the transaction "Tx-1" related to the state value of the variable Key1 read in the transaction Tx3 is inconsistent with the transaction "Tx2" related to the current state of the variable Key1.

[0106] After determining that the transaction Tx3 has failed to execute, the host 100 executes step S223 to notify the computing device 210 to re-execute the transaction Tx3. In one embodiment, the host 100 may include the current state value of the variable Key1 and the associated transaction "Tx2, V12" in the above notification, so that the computing device 210 can re-execute the transaction Tx3 based on the state value V12. After sending "Tx2, V12" to the computing device 210, the host 100 may correspondingly record "Tx3, Tx2" in the entry associated with Key1 and the computing device 210 in the global buffer to indicate that the state value of the variable Key1 written by the transaction Tx2 was read during the execution of the transaction Tx3. Assuming that transaction Tx3 also includes a write operation on variable key1, after the host 100 determines that transaction Tx3 has failed to execute, since transaction Tx3 has not been submitted at this time, only the information corresponding to the computing device 210 and key1 in the global buffer may record the reading of the status value of key1 written by transaction Tx3 by other transactions. Therefore, the host 100 can also search for other transactions that have read the status value of variable Key1 written by transaction Tx3 from the information corresponding to the computing device 210 and key1 in the global buffer, and notify the computing device 210 to re-execute the other transaction.

[0107] After receiving "Tx2, V12", the computing device 210 may record "Tx2, V12" between "Tx-1, V0" and "Tx5, V15" in the buffer 1 (eg, Figure 3 ), to indicate that V12 is the state value written by transaction Tx2. In the process of re-executing transaction Tx3, computing device 210 can read the state value corresponding to the largest transaction number less than 3 in the state value of variable key1 from cache 1 (i.e., V12 corresponding to Tx2), and can also modify "Key1, Tx-1" to "Key1, Tx2" in buffer 2. Afterwards, computing device 210 can re-execute transaction Tx3 based on state value V12, and send the execution result obtained by re-execution to host 100.

[0108] In addition to the operation of reading the variable Key1, the transaction Tx3 may also include an operation of writing the variable Key1 after the reading operation, for updating the state of the variable Key1 to a new state (e.g., V13). In this case, the computing device 210, in the process of executing the transaction Tx3 through the above step S215, performs the operation of writing the variable Key1 after performing the operation of reading the variable Key1. Figure 5 A flow chart of a method for writing a variable in a blockchain node provided in an embodiment of this specification is shown.

[0109] like Figure 5As shown, in step S501, the computing device 210 performs a write operation on the variable Key1, specifically, writes the state value V13 written to the variable Key1 in the read-write set of the transaction Tx3.

[0110] In step S503 , the computing device 210 updates the buffer 1 based on the above-mentioned write operation.

[0111] Specifically, the computing device 210 writes the state value "V13" written in the execution of transaction Tx3 in association with the variable Key1 in the buffer 1. In one embodiment, the computing device 210 executes transactions in order of transaction numbers from small to large, so the computing device 210 may only write "V13" in association with the variable Key1 in the buffer 1, and delete the previous old state value of the variable Key1.

[0112] In another embodiment, the computing device 210 executes multiple transactions in parallel, so that the computing device 210 can Figure 3 As shown in , "Tx3, V13" is added between "Tx-1, V0" and "Tx5, V15" in the entry of the variable Key1 to indicate that transaction Tx3 writes to the variable key1, and transaction Tx3 corresponds to the state value V13.

[0113] The computing device 210 may perform step S505 after performing the above operation, and send the status update information of the variable Key1 to the host 100. In one embodiment, the computing device 210 may send the information including "Key1, Tx3, V13" to the host 100 immediately after performing the above write operation. In another embodiment, the computing device 210 may send the execution result of the transaction Tx3 to the host 100 after completing the execution of the transaction Tx3, and the execution result includes the value of the variable written in the process of executing the transaction Tx3, thereby sending the status update information of the variable Key1 to the host 100.

[0114] After receiving the status update information of the variable Key1, the host 100 executes step S507, determines the information of the transaction that needs to be re-executed in each computing device based on the status update information, and notifies the corresponding computing device in step S509. The host 100 may execute steps S507 and S509 immediately after receiving the status update information, or after submitting the transaction Tx3.

[0115] Specifically, reference Figure 4, assuming that "Tx5, Tx2" is recorded in association with the variable Key1 and the computing device 210 in the global buffer, indicating that the state value of the variable Key1 written by the transaction Tx2 is read during the execution of the transaction Tx5, the submission order of the transaction Tx2 is before the transaction Tx3, and the execution of the transaction Tx3 updates the state value of the variable Key1, therefore, the host 100 can determine that the wrong (or outdated) state value of the variable Key1 is read during the execution of the transaction Tx5, so the transaction Tx5 needs to be re-executed. The host 100 can then notify the computing device 210 to re-execute the transaction Tx5. Similarly, assuming that the transaction Tx5 includes the writing of the variable key2, after the host 100 determines that the execution of the transaction Tx5 fails, the host 100 can also search for other transactions that read the state value of the variable Key2 written by the transaction Tx5 from the information corresponding to the computing device 210 and key2 in the global buffer, and notify the computing device 210 to re-execute the other transactions. After receiving the notification, the computing device 210 re-executes the transaction Tx5 in step S511. When the computing device 210 is re-executing transaction Tx5, since "Tx3, V13" has been added to the entry of variable Key1 in buffer 1 through the previous execution of transaction Tx3, the computing device 210 can read the status value "V13" of variable Key1 from buffer 1 to execute transaction Tx5, so that transaction Tx5 reads the correct status value.

[0116] Also refer to Figure 4 , assuming that "Tx4, Tx2" is recorded in association with the variable Key1 and the computing device 220 in the global buffer, it means that the state value of the variable Key1 written by the transaction Tx2 is read during the execution of the transaction Tx4, the submission order of the transaction Tx2 is before the transaction Tx3, and the execution of the transaction Tx3 updates the state value of the variable Key1. Therefore, it can be determined that the wrong state value of the variable Key1 is read during the execution of the transaction Tx4, so the transaction Tx4 also needs to be re-executed, and the host 100 can similarly perform step S211 to notify the computing device 220 to re-execute the transaction Tx4. The computing device 220 re-executes the transaction Tx4 in step S513. In one embodiment, the host 100 can send "Tx3, V13" together with the notification to the computing device 220, so that the computing device 220 can re-execute the transaction Tx4 based on the state value "V13".

[0117] In one embodiment, the host 100 may notify the computing device 220 that transaction Tx4 needs to be re-executed after transaction Tx3 is submitted. After transaction Tx3 is submitted, the host 100 modifies the current state of the variable Key1 to "V13" in the global buffer, and modifies the identifier of the related transaction to "Tx3". When the computing device 220 re-executes transaction Tx4, it requests to read the current state of the variable Key1 (i.e., "V13") and the related transaction number (i.e., "Tx3") from the host 100, so that the computing device 220 can obtain the correct state value for re-executing transaction Tx4. After sending "Tx3 V13" to the computing device 220, the host 100 may delete "Tx4Tx2" associated with the variable Key1 and the computing device 220 in the global buffer, and record "Tx4Tx3" at this location.

[0118] refer to Figure 3 , it is assumed that the computing device 210 performs a read operation on the variable Key1 in transaction Tx5 before executing the above-mentioned write operation of transaction Tx3, reads the state value V0, and records "Key1, Tx-1" in the buffer 3 corresponding to transaction Tx5 in the memory 212. It is assumed that after the computing device 210 records "Tx3 V13" in the buffer 1 as described above, it performs a read operation on the variable Key1 in transaction Tx5 again, and the state value read at this time is "V13". After reading the state value V13, the computing device 210 determines that "Key1Tx-1" has been recorded in the buffer 3 during the process of recording "Key1 Tx3" in the buffer 3, so that it can be determined that the transaction Tx5 reads an incorrect state value in the previous execution, so the execution of transaction Tx5 is rolled back and the transaction Tx5 is re-executed. In particular, in rolling back the execution of transaction Tx5, it can include deleting "Tx5 V15" in the entry of variable Key1 in buffer 1 and deleting "Key1, Tx-1" in buffer 3.

[0119] In the process of re-executing transaction Tx5, when the computing device 210 reads the variable Key1 for the first time in executing transaction Tx5, it will read "Tx3 V13" according to the content in buffer 1, thereby reading the correct state value.

[0120] References Figure 2-Figure 5 A transaction execution scheme provided by an embodiment of the present specification is described. Through this scheme, the states of variables accessed during the transaction execution process are cached separately in multiple computing devices that do not share memory in a blockchain node. For variables that are frequently read-only, the state values ​​of the variables cached in the computing devices are correct state values. The computing devices can read the state values ​​of the variables directly from the local memory without going through the host, thereby reducing the time for communication with the host, reducing the transaction execution time, and improving system performance.

[0121] Figure 6 This is an architecture diagram of a computing device for a blockchain node provided in an embodiment of this specification, wherein the blockchain node also includes a host, and the computing device is used to execute Figure 2 or Figure 5 The method shown comprises:

[0122] The receiving unit 61 is configured to receive a portion of transactions in a first block from a host, wherein the portion of transactions includes a first transaction, and the first transaction includes a read operation on a first variable;

[0123] a reading unit 62, configured to, after starting to execute the first transaction, read the first state of the first variable from the memory at least in the case where it is determined that the first state of the first variable is stored in the memory, and obtain an execution result of the first transaction according to the first state;

[0124] The sending unit 63 is used to send the execution result and information indicating the status read during the execution of the first transaction to the host.

[0125] Figure 7 This is an architecture diagram of a host for a blockchain node provided in an embodiment of this specification, wherein the blockchain node also includes a computing device, and the host is used to execute Figure 2 or Figure 5 The method shown comprises:

[0126] A sending unit 71 is used to send part of the transactions in the first block to the computing device, wherein the part of the transactions includes a first transaction, the first transaction includes a read operation on a first variable, the host includes a first storage space, the first storage space is used to store a plurality of first information of the first block during the execution of the first block, the plurality of first information respectively indicating current states of a plurality of variables accessed during the execution, and the computing device includes a second storage space;

[0127] a receiving unit 72, configured to receive an execution result of the first transaction and second information from the computing device, wherein the second information indicates that a first state of a first variable stored in the second storage space is read during execution of the first transaction;

[0128] The submitting unit 73 is configured to submit the first transaction after sequentially submitting transactions in the first block whose submission order is before the first transaction, and when it is determined according to the global execution information that the first state is the current state of the first variable.

[0129] It should be understood that the descriptions such as “first” and “second” in this article are only used to distinguish similar concepts for the sake of simplicity of description and do not have any other limiting effect.

[0130] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0131] 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.

[0132] Those of ordinary skill in the art should also be further aware that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, computer software or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to the function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those of ordinary skill in the art can use different methods to implement the described functions for each specific application, but this implementation should not be considered to be beyond the scope of the present application. Among them, the software module can be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the technical field.

[0133] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A transaction execution method, the method being executed by a blockchain node, the blockchain node comprising a host and a first computing device, the method comprising: The host sends part of the transactions in the first block to the first computing device, wherein the part of the transactions includes a first transaction, the first transaction includes a read operation on a first variable, the host includes a first storage space, the first storage space is used to store a plurality of first information of the first block during the execution of the first block, the plurality of first information respectively indicating current states of a plurality of variables accessed during the execution, and the first computing device includes a second storage space; After the first computing device starts to execute the first transaction, at least when it is determined that the first state of the first variable is stored in the second storage space, the first computing device reads the first state of the first variable from the second storage space, obtains an execution result of the first transaction according to the first state, and sends the execution result and second information to the host, wherein the second information indicates that the first state is read during the execution of the first transaction; After sequentially submitting transactions in the first block whose submission order is before the first transaction, the host submits the first transaction when determining that the first state is the current state of the first variable according to the first information and the second information.

2. The method according to claim 1, further comprising: After the host sequentially submits the transactions in the first block whose submission order is before the first transaction, and if it is determined based on the first information and the second information that the first state is not the current state of the first variable, the host notifies the first computing device to re-execute the first transaction.

3. The method according to claim 1, further comprising, before executing the first transaction, the first computing device sending a read request for the first variable corresponding to a second transaction to the host; The host sends the current first state of the first variable and an identifier of a third transaction to the first computing device in response to a read request of the first computing device, wherein the third transaction is a transaction for writing the first state; The first computing device records first state information of the first variable in the second storage space, wherein the first state information includes the first state and an identifier of the third transaction, wherein the second information is an identifier of the third transaction.

4. The method according to claim 3 further includes, after the host sends the first state of the first variable and the identifier of the third transaction to the first computing device, recording first execution information corresponding to the first variable and the first computing device in the first storage space, the first execution information including the second transaction and the third transaction, indicating that the state written by the third transaction was read during the execution of the second transaction.

5. The method according to claim 3 further includes, after receiving the execution result and the second information, the host records second execution information corresponding to the first variable and the first computing device in the first storage space, the second execution information including the first transaction and the third transaction, indicating that the status written by the third transaction was read during the execution of the first transaction.

6. According to the method of claim 4 or 5, the first information of the first variable is an identifier of a transaction that writes the current state of the first variable, and determining the first state as the current state of the first variable based on the first information and the second information includes, when the first information of the first variable is an identifier of the third transaction, determining the first state as the current state of the first variable.

7. The method according to claim 3, further comprising: The host sends the submission order of the partial transactions to the first computing device; The reading of the first state of the first variable comprises: reading the first state when it is determined that the first state information of the first variable is stored in the second storage space and the submission order of the third transaction is before the first transaction.

8. The method according to claim 3, further comprising: After storing the first state information in the second storage space, the first computing device re-executes the first transaction if it is determined that the second storage space stores information indicating that the first transaction has read the state of the first variable written by the fourth transaction.

9. The method according to claim 8 further includes: when the first computing device determines that the second storage space does not store the reading information of the first variable by the first transaction, recording in the second storage space information that the first transaction reads the state of the first variable written by the third transaction, and after obtaining the execution result of the first transaction, the first computing device obtains the second information from the second storage space.

10. The method according to any one of claims 3 to 5, wherein the first transaction further includes a write operation on the second variable, and the method further includes: After executing the write operation, the first computing device records second state information of the second variable in the second storage space, where the second state information includes an identifier of the first transaction and a second state of the second variable written by the first transaction.

11. The method according to claim 10, further comprising: After submitting the first transaction, the host records the current state of the second variable as the second state, and records the first transaction as a transaction for writing the second state of the second variable.

12. The method according to claim 10, wherein the first storage space stores third execution information corresponding to the second variable and the second computing device, the third execution information includes a fifth transaction and a sixth transaction, indicating that the state of the second variable written by the sixth transaction is read during the execution of the fifth transaction, the submission order of the fifth transaction is after the first transaction, and the submission order of the sixth transaction is before the first transaction, and the method further comprises: After receiving the execution result, or after submitting the first transaction, or before submitting the fifth transaction, the host notifies the second computing device to re-execute the fifth transaction according to the third execution information.

13. The method according to claim 1, wherein: The first computing device is a computing unit included in the FPGA chip.

14. A transaction execution method, the method being executed by a computing device included in a blockchain node, the blockchain node also including a host, the method comprising: Receiving a portion of transactions in a first block from a host, wherein the portion of transactions includes a first transaction, and the first transaction includes a read operation on a first variable; After starting to execute the first transaction, at least in the case of determining that a first state of the first variable is stored in a storage space of the computing device, reading the first state of the first variable from the storage space, and obtaining an execution result of the first transaction according to the first state; The execution result and information indicating a status of reading during execution of the first transaction are sent to the host.

15. The method according to claim 14 further comprises, before executing the first transaction, sending a read request for the first variable corresponding to the second transaction to the host; receiving from the host the current first state of the first variable and an identifier of a third transaction, wherein the third transaction is a transaction for writing the first state; and recording first state information of the first variable in the storage space, wherein the first state information includes the first state and the identifier of the third transaction, wherein: The information indicating the state of reading during the execution of the first transaction is an identifier of the third transaction.

16. The method according to claim 15, further comprising: receiving a submission order of the partial transaction from a host, wherein at least in the case of determining that the first state of the first variable is stored in the storage space, reading the first state of the first variable comprises: In the case where it is determined that the first state information of the first variable is stored in the storage space and the submission order of the third transaction is before the first transaction, the first state is read.

17. The method according to claim 15, further comprising: After storing the first state information of the first variable in the storage space, if it is determined that the storage space stores information that the first transaction has read the state of the first variable written by the fourth transaction, the first transaction is re-executed.

18. The method according to claim 17 further includes, in a case where it is determined that the storage space does not store the read information of the first variable by the first transaction, recording in the storage space information on the state of the first variable written by the third transaction read by the first transaction, and after obtaining the execution result of the first transaction, obtaining from the storage space the information indicating the read status during the execution of the first transaction.

19. The method according to claim 14, wherein the first transaction further comprises a write operation on a second variable, and the method further comprises: After executing the write operation, second state information of the second variable is recorded in the storage space, where the second state information includes an identifier of the first transaction and a second state of the second variable written by the first transaction.

20. A transaction execution method, the method being executed by a host included in a blockchain node, the blockchain node also including a computing device, the method comprising: Sending part of the transactions in the first block to the computing device, wherein the part of the transactions includes a first transaction, the first transaction includes a read operation on a first variable, the host includes a first storage space, the first storage space is used to store a plurality of first information of the first block during the execution of the first block, the plurality of first information respectively indicating current states of a plurality of variables accessed during the execution, and the computing device includes a second storage space; receiving, from the computing device, an execution result of the first transaction and second information, wherein the second information indicates that a first state of a first variable stored in the second storage space is read during execution of the first transaction; After sequentially submitting transactions in the first block whose submission order is before the first transaction, and when it is determined that the first state is the current state of the first variable according to the first information and the second information, the first transaction is submitted.

21. A blockchain node, comprising a host and a computing device, The host is configured to send part of the transactions in the first block to the computing device and receive the execution result of the transactions from the computing device, and the host includes a first storage space, the first storage space is used to store a plurality of first information of the first block during the execution of the first block, the plurality of first information respectively indicating the current status of a plurality of variables accessed during the execution; The computing device is configured to receive the partial transaction from the host, execute the partial transaction, and send the execution result of the transaction and the second information to the host. The computing device includes a second storage space, and the second storage space is used to store the state of the variables accessed during the execution of the partial transaction. The second information indicates the state of the variables read during the execution process.

22. The blockchain node according to claim 21, wherein: The first information is an identifier of a transaction written into the current state, the second storage space is further used to store an identifier of a second transaction corresponding to a first state of a first variable read by a first transaction in the partial transaction, the second transaction is a transaction written into the first state, and the second information is an identifier of the second transaction, The host is further configured to determine whether the first transaction is successfully executed based on the identifier of the second transaction and the first information of the first variable.

23. The blockchain node according to claim 22, wherein: The host is also configured to record execution information corresponding to the first variable and the computing device in the first storage space after receiving the execution result and the second information, the execution information including the first transaction and the second transaction, indicating that the status written by the second transaction was read during the execution of the first transaction.

24. A computing device for a blockchain node, the blockchain node further comprising a host, the computing device comprising: A receiving unit, configured to receive a portion of transactions in a first block from a host, wherein the portion of transactions includes a first transaction, and the first transaction includes a read operation on a first variable; a reading unit, configured to, after starting to execute the first transaction, read the first state of the first variable from the storage space at least when it is determined that the first state of the first variable is stored in the storage space, and obtain an execution result of the first transaction according to the first state; The sending unit is used to send the execution result and information indicating the status read during the execution of the first transaction to the host.

25. A host for a blockchain node, wherein the blockchain node also includes a computing device, and the host includes: a sending unit, configured to send part of the transactions in the first block to the computing device, wherein the part of the transactions includes a first transaction, the first transaction includes a read operation on a first variable, the host includes a first storage space, the first storage space is used to store a plurality of first information of the first block during the execution of the first block, the plurality of first information respectively indicating current states of a plurality of variables accessed during the execution, and the computing device includes a second storage space; a receiving unit, configured to receive an execution result of the first transaction and second information from the computing device, wherein the second information indicates that a first state of a first variable stored in the second storage space is read during execution of the first transaction; A submitting unit is used to submit the first transaction after sequentially submitting transactions in the first block whose submission order is before the first transaction, and when it is determined according to global execution information that the first state is the current state of the first variable, submit the first transaction.

26. A computing device comprising a memory and a processor, wherein the memory stores executable codes, and when the processor executes the executable codes, the method according to any one of claims 14 to 20 is implemented.

Citation Information

Patent Citations

  • Method and device for concurrently executing transactions in block chain

    CN110706101A

  • Cloud computing node and file management method and device

    CN113032099A