Transaction execution method, storage service, and blockchain node in a blockchain system

By rolling back the sharded data of the storage nodes and updating the reference variable values, the problem of transaction execution errors caused by storage node anomalies in the blockchain system was solved, ensuring the accuracy of transaction execution and the stability of the system.

CN116049310BActive Publication Date: 2026-04-17ANT BLOCKCHAIN TECHNOLOGY (SHANGHAI) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ANT BLOCKCHAIN TECHNOLOGY (SHANGHAI) CO LTD
Filing Date
2022-12-30
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

In a blockchain system, an abnormal restart of a storage node can cause inconsistencies in the reference variable values ​​between the blockchain node and the storage node, resulting in incorrect transaction execution results and preventing the transaction from being executed correctly.

Method used

By rolling back the sharded data of the storage node to the same block height and updating the reference variable values, the variable values ​​of the blockchain node and the storage node are made consistent, and the transaction is re-executed.

Benefits of technology

Ensuring the accuracy of transaction execution results and avoiding erroneous executions due to storage node anomalies ensures the stable operation of the blockchain system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116049310B_ABST
    Figure CN116049310B_ABST
Patent Text Reader

Abstract

A transaction execution method in a blockchain system, a storage service and a blockchain node, a single blockchain node is associated with a storage service comprising a plurality of storage nodes. The method executed by the storage service comprises: returning response data to the blockchain node according to a read request, so that the blockchain node obtains an execution result of a first transaction according to the response data; receiving a storage request initiated by the blockchain node according to the execution result, the storage request comprising a first variable value; if the variable value of a reference variable stored in the storage node is different from the first variable value, corresponding error prompt information is returned, so that the blockchain node updates the variable value of the reference variable stored in itself and the storage node to a third variable value, updates the sharding data to a first block height, and re-executes the first transaction, wherein the block corresponding to the first block height is the previous block of the block to which the first transaction belongs, and the variable value of the reference variable stored in the storage node will change when the sharding data is rolled back to the same block height.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments in this specification pertain to the field of blockchain, and particularly relate to a transaction execution method, storage service, and blockchain node in a blockchain system. Background Technology

[0002] Blockchain is a novel application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and cryptographic algorithms. In a blockchain system, data blocks are sequentially linked together to form a chain-like data structure, and a distributed ledger is cryptographically guaranteed to be immutable and unforgeable. Due to its decentralized, immutable, and autonomous characteristics, blockchain is receiving increasing attention and application. Summary of the Invention

[0003] The purpose of this invention is to provide a transaction execution method, storage service, and blockchain node in a blockchain system.

[0004] In a first aspect, a transaction execution method is provided in a blockchain system, the blockchain system including blockchain nodes, the blockchain nodes being associated with a storage service comprising multiple storage nodes, the method being applied to the storage service. The method includes: receiving a first read request initiated by the blockchain node during the execution of a first transaction, and returning response data according to the first read request, so that the blockchain node obtains the execution result of the first transaction based on the response data; receiving a first storage request initiated by the blockchain node based on the execution result of the first transaction, wherein the first storage request includes a first variable value of a reference variable stored in the blockchain node; determining whether a second variable value of the reference variable stored in the storage node is the same as the first variable value, and if they are different, returning an error message to the blockchain node, so that the blockchain node updates the variable values ​​of the reference variables stored in the blockchain node and the plurality of storage nodes to the same third variable value, updates the shard data stored in the plurality of storage nodes to a first block height, and re-executes the first transaction, wherein the block corresponding to the first block height in the blockchain system is the block preceding the block to which the first transaction belongs, and when the shard data stored in the plurality of storage nodes is rolled back to the same block height, the variable values ​​of the reference variables stored in the plurality of storage nodes change.

[0005] Secondly, a transaction execution method is provided in a blockchain system, the blockchain system including a blockchain node, the blockchain node being associated with a storage service comprising multiple storage nodes, the method being applied to the blockchain node. The method includes: during the execution of a first transaction, sending a first read request to the storage service, obtaining response data returned by the storage service according to the first read request, and obtaining the execution result of the first transaction according to the response data; sending a first storage request to the storage service according to the execution result of the first transaction, wherein the first storage request includes a first variable value of a reference variable stored in the blockchain node, such that if the variable value of the reference variable stored in each of the plurality of storage nodes is different from the first variable value, the storage service returns an error message; in response to the error message, updating the variable value of the reference variable stored in the blockchain node and the plurality of storage nodes to the same third variable value, updating the shard data stored in each of the plurality of storage nodes to a first block height, and re-executing the first transaction, wherein the block corresponding to the first block height in the blockchain system is the block preceding the block to which the first transaction belongs, and the variable value of the reference variable stored in each of the plurality of storage nodes changes when the shard data stored in each of the plurality of storage nodes is rolled back to the same block height.

[0006] Thirdly, a storage service in a blockchain system is provided, the blockchain system including blockchain nodes, the blockchain nodes being associated with the storage service, and the storage service including multiple storage nodes. The storage node is configured to: receive a first read request initiated by the blockchain node during the execution of a first transaction, and return response data according to the first read request, so that the blockchain node obtains the execution result of the first transaction based on the response data; receive a first storage request initiated by the blockchain node based on the execution result of the first transaction, wherein the first storage request includes a first variable value of a reference variable stored in the blockchain node; determine whether a second variable value of the reference variable stored in the storage node is the same as the first variable value, and if they are different, return an error message to the blockchain node, so that the blockchain node updates the variable values ​​of the reference variables stored in the blockchain node and the plurality of storage nodes to the same third variable value, updates the shard data stored in the plurality of storage nodes to the first block height, and re-executes the first transaction. In the blockchain system, the block corresponding to the first block height is the block preceding the block to which the first transaction belongs. When the shard data stored in the plurality of storage nodes is rolled back to the same block height, the variable values ​​of the reference variables stored in the plurality of storage nodes change.

[0007] Fourthly, a blockchain node in a blockchain system is provided, the blockchain node being associated with a storage service that includes multiple storage nodes. The blockchain node includes: a transaction execution unit, configured to send a first read request to the storage service during the execution of a first transaction, obtain response data returned by the storage service according to the first read request, and obtain the execution result of the first transaction based on the response data; a block management unit, configured to send a first storage request to the storage service according to the execution result of the first transaction, wherein the first storage request includes a first variable value of a reference variable stored in the blockchain node, such that if the variable value of the reference variable stored in each of the plurality of storage nodes is different from the first variable value, the storage service returns an error message; and, in response to the error message, updates the variable value of the reference variable stored in the blockchain node and the plurality of storage nodes to the same third variable value, updates the shard data stored in each of the plurality of storage nodes to a first block height, and triggers the transaction execution unit to re-execute the first transaction, wherein the block corresponding to the first block height in the blockchain system is the block preceding the block to which the first transaction belongs, and when the shard data stored in each of the plurality of storage nodes is rolled back to the same block height, the variable value of the reference variable stored in each of the plurality of storage nodes changes.

[0008] Fifthly, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed in a computer, causes the computer to perform the method described in the first or second aspect.

[0009] In the embodiments of this specification, when the storage service is running normally, the reference variable values ​​stored in its associated blockchain node and its multiple storage nodes are the same. When an abnormal storage node occurs in the storage service, the shard data stored in each of the multiple storage nodes can be rolled back to the same block height, and the reference variable values ​​stored in each of the multiple storage nodes will change, resulting in different variable values ​​for the reference variables stored in the blockchain node and the multiple storage nodes. Correspondingly, because the shard data has been rolled back, the execution result of the first transaction obtained by the blockchain node based on the response data from the storage service is not a correct execution result. The storage request initiated by the blockchain node to the storage service based on the execution result of the first transaction includes the variable values ​​of the reference variables stored by itself. The storage service can return an error message to the blockchain node to indicate that the blockchain node failed to execute the first transaction correctly by determining that the variable values ​​in the storage request are different from the variable values ​​of the reference variables stored in the storage node. Furthermore, based on the error message, the blockchain node can reset the variable values ​​of the reference variables stored in itself and multiple storage nodes to the same third variable value. Then, based on the third variable value, it can update the shard data stored in multiple storage nodes to the first block height. The block corresponding to the first block height is the block preceding the block to which the first transaction belongs. Based on the updated shard data in the storage service, the first transaction is then correctly executed again. Attached Figure Description

[0010] To more clearly illustrate the technical solutions of the embodiments in this specification, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments recorded in this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0011] Figure 1 This is an architecture diagram of a blockchain system provided in the embodiments of this specification;

[0012] Figure 2 This is a system framework diagram of the technical solutions provided in the embodiments of this specification;

[0013] Figure 3 This is an example of a process where the storage service rolls back fragmented data and changes the value of a reference variable.

[0014] Figure 4 This is a flowchart illustrating a transaction execution method in a blockchain system provided in the embodiments of this specification;

[0015] Figure 5This is a schematic diagram of the structure of a blockchain node in a blockchain system provided in the embodiments of this specification. Detailed Implementation

[0016] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this specification, and not all embodiments. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this specification.

[0017] Figure 1 This is an exemplary architecture diagram of a blockchain system provided in the embodiments of this specification. The blockchain system may include N blockchain nodes, wherein... Figure 1 The example shows eight blockchain nodes, numbered 1 through 8. The connections between the nodes schematically represent P2P (Peer-to-Peer) connections, such as Transmission Control Protocol (TCP) connections, which are used to support the transfer of data between different nodes.

[0018] In a blockchain system, the system data that needs to be persistently stored can be divided into two parts: block data and state data.

[0019] Block data includes one or more blocks in ascending order of block height (or block number). A single block may include a block header and a block body. The block header may include the previous block's block hash (or parent hash), timestamp, block number (BlockNum), state root hash (State_Root), transaction root hash (Transaction_Root), and receipt root hash (Receipt_Root), etc. The block body may include a set of transactions and a set of receipts.

[0020] For any k-th block, based on the state data with block height (or version) k-1, execute multiple transactions in the transaction set belonging to the k-th block, arranged in sequence, and obtain the execution results of these transactions. Then, update the state data with block height k-1 based on the execution results of these transactions to obtain the state data with block height k.

[0021] For any blockchain node in a blockchain system, it may use a storage service comprising multiple storage nodes to distribute block data and / or state data. See also Figure 2As shown, node 1 in the blockchain system is associated with storage service 1. Storage service 1 includes m storage nodes, from storage node 1 to storage node m. The state data corresponding to block height k in the blockchain system is divided into m shards and stored in the m storage nodes. When node 1 executes multiple transactions belonging to block k+1, it can query the target data from the m storage nodes as needed, and obtain the execution results of the multiple transactions based on the queried target data. Then, it can initiate a data storage request for block height k+1 to storage service 1 based on the execution results of the multiple transactions. The m storage nodes can update their respective stored shards based on the data storage request from node 1. The updated shards correspond to block height k+1. In other words, the m updated shards can form the state data corresponding to block height k+1 in the blockchain system.

[0022] When a storage node in a storage service experiences an anomaly, such as a node crashing and then restarting, the block height corresponding to the shard data it stores may differ from the block heights corresponding to the shard data stored by other storage nodes. For example, if m storage nodes (nodes 1 through m) receive data storage requests for block height k+1, and the storage service process of node 1 experiences a code exception or memory overflow, the storage service process will be restarted. In this case, node 1 cannot properly complete the data storage request based on block height k+1 and update its stored shard data for block height k to the corresponding block height k+1. Thus, it's possible that the shard data stored in node 1 corresponds to block height k, while the shard data stored in nodes 2 through m each corresponds to block height k+1, causing the blockchain nodes to be unable to continue executing transactions correctly in subsequent processes.

[0023] This specification provides a transaction execution method, storage service, and blockchain node in a blockchain system. When the storage service is running normally, the reference variable values ​​stored in the associated blockchain node and its multiple storage nodes are the same. When an abnormal storage node occurs in the storage service, the shard data stored in each of the multiple storage nodes can be rolled back to the same block height, and the reference variable values ​​stored in each of these multiple storage nodes will change, resulting in different variable values ​​for the reference variables stored in the blockchain node and the multiple storage nodes. Correspondingly, because the shard data has been rolled back, the execution result of the first transaction obtained by the blockchain node based on the response data from the storage service is not a correct execution result. The storage request initiated by the blockchain node to the storage service based on the execution result of the first transaction includes the variable values ​​of the reference variables stored by itself. The storage service can determine that the variable values ​​in the storage request are different from the variable values ​​of the reference variables stored in the storage node and return an error message to the blockchain node to indicate that the blockchain node failed to execute the first transaction correctly. Furthermore, based on the error message, the blockchain node can reset the variable values ​​of the reference variables stored in itself and multiple storage nodes to the same third variable value. Then, based on the third variable value, it can update the shard data stored in multiple storage nodes to the first block height. The block corresponding to the first block height is the block preceding the block to which the first transaction belongs. Based on the updated shard data in the storage service, the first transaction is then correctly executed again.

[0024] The following is in conjunction with the above. Figure 2 The system framework shown in this specification describes in detail the technical solutions provided in the embodiments.

[0025] Figure 3 This is a schematic diagram illustrating the process of rolling back fragmented data and changing the value of a reference variable in a storage service provided as an example. See also... Figure 3 As shown, the storage service involved in this process is, for example, storage service 1 associated with node 1 in the blockchain system. Storage service 1 includes, for example, m storage nodes, from storage node 1 to storage node m. Storage service 1 to which these m storage nodes belong may also include a master node. If any of these m storage nodes, such as storage node 1, experiences an anomaly, it can be resolved through methods such as... Figure 3 The process shown causes the fragment data stored on each of the m storage nodes to be rolled back to the same block height, and causes the value of the reference variable `round` stored on each of the m storage nodes to be different from the value of the reference variable `round` stored on node 1. See also Figure 3 As shown, the process may include some or all of the following steps S31 to S39.

[0026] In step S31, after a restart, storage node 1 changes the value of its stored reference variable round from v1 to v2.

[0027] When storage service 1 is running normally, the reference variable round stored in storage nodes 1 to m all have the same value, for example, v1. After storage node 1 is restarted, for example, the value of the reference variable round can be increased based on v1 according to a predetermined step size, so that the value of the reference variable round stored in storage node 1 changes to v2, which is different from v1.

[0028] Optionally, in step S32, storage node 1 sends a prompt message to the master node.

[0029] In response to the prompt message from storage node 1, the master node executes step S33 to obtain the block height and the variable value of the reference variable round corresponding to the shard data stored by each of the m storage nodes.

[0030] Step S33 can also be triggered by other means. For example, the master node can poll the storage service processes of m storage nodes to see if they are online. If it finds that the storage service process of a certain storage node is offline for some reason, the master node can request the m storage nodes to provide the master node with the block height corresponding to the shard data they store and the variable value of the reference variable round they store. After the master node has obtained the block height corresponding to the shard data stored by each of the m storage nodes and the variable value of the reference variable round they store, it will continue to execute step S34.

[0031] In step S34, the master node determines the second block height, which is the smallest among the m block heights it has acquired, and determines a variable value v3, which is different from v1 and v2, based on the m variable values ​​of the reference variable round it has acquired.

[0032] Taking the case where only storage node 1 among m storage nodes experiences an abnormal restart, the value of the reference variable round obtained by the master node from storage node 1 is v2, and the value of the reference variable round obtained from the other m-1 storage nodes is v1. The master node can determine the variable value v2 with the largest value, and increase v2 by a predetermined step size to obtain a variable value v3 that is different from v1 and v2.

[0033] In step S35, the master node sends a data rollback request containing the second block height and variable value v3 to m storage nodes.

[0034] All m storage nodes that receive the data rollback request can continue to execute the following steps S36 and S37.

[0035] In step S36, the value of the stored reference variable round is changed to v3.

[0036] In step S37, it is determined whether the block height corresponding to the stored fragment data is greater than the second block height.

[0037] If any storage node determines in step S37 that the block height corresponding to its stored fragmented data is greater than the second block height, the storage node can continue to execute step S38; otherwise, the storage node can directly end the current process or return a response message to the master node that it has completed the data rollback.

[0038] In step S38, the stored fragment data is rolled back to the second block height.

[0039] For example, storage node 1 restarts for some reason, while the other m-1 storage nodes operate normally. The other m-1 storage nodes may have already completed updating their stored shard data to the corresponding block height k+1 based on the storage request from node 1. Storage node 1 may have failed to process the storage request correctly, resulting in its stored shard data having a block height of k. In this case, the second block height can be block height k. Storage node 1 does not need to perform the data rollback operation through step S38. The other m-1 storage nodes can perform the data rollback operation through step S38, rolling back their stored shard data from block height k+1 to block height k, so that the shard data stored by each of the m storage nodes corresponds to the same block height k.

[0040] Storage nodes can record changes to the sharded data they store through persistent data or memory. For example, if storage node m stores sharded data through data storage system A, the storage engine of data storage system A can record, through memory or persistent data, changes in the sharded data at block height k stored in storage node m, from sharded data at block height k+1 to sharded data at block height k+1. If the second block height is k, storage node m can trigger the storage engine of data storage system A to roll back the sharded data stored in data storage system A directly to block height k based on these records.

[0041] The foregoing Figure 3 An example describes a situation where a storage node in a storage service restarts for some reason, causing inconsistencies in the block heights of the shard data stored on each of the m storage nodes. The process involves rolling back the shard data stored on each of the m storage nodes to the same block height and modifying the value of the reference variable `round` stored on each of the m storage nodes to differ from the value of `round` stored in the relevant blockchain nodes. However, it is understood that other methods may also be used. Figure 3Other methods can be used to complete the above process; for example, if storage node 1 restarts for some reason, it does not need to change the value of the variable 'round' stored in it from v1 to v2, the master node does not need to perform the processing related to the variable value, and each of the m storage nodes can increase the value of their respective stored variable v1 by a predetermined step size after receiving a data rollback request containing the height of the second block, obtain the variable value v2, and change the value of their respective stored reference variable 'round' to v2.

[0042] Each of the m storage nodes in storage service 1 can also maintain a state machine that indicates whether it is performing a data rollback operation. For example, when any storage node receives a data rollback request from the master node, the storage node can set its maintained state machine from 0 to 1, indicating that storage service 1 is self-healing. The storage node completes the aforementioned step S38. Alternatively, after the storage node determines in step S37 that the block height corresponding to its stored shard data is not greater than the second block height, it can reset its maintained state machine from 1 to 0, indicating that storage service 1 can provide normal service.

[0043] Figure 4 This is a flowchart illustrating a transaction execution method in a blockchain system provided in an embodiment of this specification. The method involves node 1 in the blockchain system, and a storage service 1 associated with node 1 and including m storage nodes, from storage node 1 to storage node m. When the storage service 1 is running normally, the reference variable `round` stored in node 1 and each of the m storage nodes included in the storage service 1 has the same value, for example, the aforementioned variable value `v1`. The method exemplarily describes how the storage service 1, by including the aforementioned... Figure 3 Using various methods, including those mentioned above, to roll back the shard data stored by each of the m storage nodes and change the value of the reference variable `round`, node 1 correctly executes transaction Tx1 based on the shard data stored by each of the m storage nodes. See also... Figure 4 As shown, the method may include, but is not limited to, some or all of the following steps S41 to S48.

[0044] In step S41, during the execution of transaction Tx1, node 1 sends a read request R1 to storage service 1, obtains the response data returned by storage service 1 based on read request R1, and obtains the execution result of transaction Tx1 based on the response data.

[0045] In the blockchain system, node 1 can send a read request R1 to storage service 1 as needed during the execution of transaction Tx1. The read request R1 may include, for example, the keys of several state variables that need to be queried during the execution of transaction Tx1. Correspondingly, the read request R1 may be received by several storage nodes among the m storage nodes included in storage service 1.

[0046] In one possible implementation, for a storage node, such as storage node 1, that receives a read request R1, if the storage node is performing a data rollback operation when it receives the read request R1, the storage node can typically return an error message E1 to node 1 in the blockchain system, allowing node 1 in the blockchain system to continue initiating the read request R1 based on the error message E1. If the storage node is not performing a data rollback operation when it receives the read request R1, the storage node can directly read the corresponding response data from its stored shard data based on the read request R1 and return the response data to node 1 in the blockchain system, wherein the response data includes, for example, a value corresponding to the key of the aforementioned state variables.

[0047] In another possible implementation, for a storage node such as storage node 1 that receives a read request R1, the storage node may also return response data directly without distinguishing whether it is in the process of performing a data rollback operation.

[0048] Node 1 may include a block management service (block_server) and several computing services (computing_server). The computing services are stateless and primarily used to execute transactions within the blockchain system. The block management service is a stateful service, primarily used to invoke the computing services to execute transactions and update data stored through storage service 1, such as updating the shard data stored by the m storage nodes included in storage service 1 on demand. In this case, the block management service and the computing services can each store the value of the reference variable `round`. Furthermore, the aforementioned storage service 1 can also return its modified value of the reference variable `round`, such as the aforementioned variable value `v3`, to the computing service in Node 1 used to execute the aforementioned step S41. If the computing service discovers that the variable value `v3` differs from the value `v1` of the reference variable `round` it stores, it can determine that storage service 1 has performed a data rollback operation and execute other pre-defined transactions based on this discovery.

[0049] In step S42, node 1 sends a storage request W1 to storage service 1 based on the execution result of transaction Tx1. The storage request W1 includes the variable value v1 of the reference variable round stored in node 1.

[0050] After node 1 completes the execution of each transaction in the target block to which transaction Tx1 belongs, it can initiate a storage request W1 to storage service 1 based on the execution results of each transaction belonging to the target block, such as the write set of each transaction belonging to the target block. This storage request W1 is used to update the shard data stored by each of the m storage nodes to the corresponding block height. The storage request W1 also includes the variable value v1 of the reference variable round stored in node 1. Where node 1 includes a block management service and several computing services, the aforementioned step S42 can be specifically executed by the aforementioned block management service. In this case, the variable value of the reference variable round stored in the computing service may have been updated to the variable value v3, while the variable value of the reference variable round included in W1 should be the unchanged variable value v1 stored by the block management service itself.

[0051] In step S43, the storage service 1 determines whether the value of its stored reference variable round is the same as that of v1.

[0052] The m storage nodes included in storage service 1 can each determine whether the value of their own stored reference variable `round` is the same as the value `v1` in storage request W1. Referring to the previous text, if any of the m storage nodes restarts for any reason, storage service 1 will, through the aforementioned... Figure 3 The method includes performing a data rollback operation and changing the value of the reference variable round stored by each of the m storage nodes from v1 to v3. Therefore, in step S43, storage service 1 will determine that the value of its stored reference variable round is different from v1, and thus refuse to update the shard data stored by each of the m storage nodes according to the storage request w1, and execute the following step S44.

[0053] In step S44, the storage service 1 returns error message E2 to node 1.

[0054] Node 1 can detect through error message E2 that it failed to execute transaction Tx1 correctly, and then execute the following step S45, changing the variable value of the reference variable round stored by Node 1 and m storage nodes to the same variable value v4.

[0055] Node 1, such as the block management service in Node 1, can update the value of its stored reference variable `round` to a value `v4`, which is different from the value `v1`. Then, it sends a state synchronization request to storage service 1, which includes the value `v4`, causing the `m` storage nodes included in storage service 1 to update their respective stored values ​​of the reference variable `round` to `v4`. In another possible implementation, Node 1 does not need to change the value of its stored reference variable `round`. Instead, it directly sends a state synchronization request to storage service 1, which includes the value `v1` of the reference variable `round` stored in Node 1, such as the block management service in Node 1, causing the `m` storage nodes included in storage service 1 to update their respective stored values ​​of the reference variable `round` to `v1`.

[0056] Next, in step S46, node 1 obtains the second block height corresponding to the fragmented data stored by each of the m storage nodes in storage service 1. For example, node 1 can obtain the second block height from the master node of storage service 1.

[0057] Next, in step S47, node 1 sends a storage request W2 to storage service 1 according to the second block height. The storage request W2 includes the variable value V4 of the reference variable round stored in the node, so that the m storage nodes of storage service 1 update their respective stored shard data to the first block height. The block corresponding to the first block height in the blockchain system is the block before the target block to which transaction Tx1 belongs.

[0058] For any storage node included in storage service 1, after receiving storage request W2 including variable value v4, it will first determine whether the variable value of the reference variable round stored by the storage node is the same as the variable value v4 included in storage request W2. If they are the same, it will update the shard data stored by the storage node to the second block height according to storage request W2.

[0059] For example, when node 1 obtains the second block height from the master node of storage service 1, which is block height k, and the block height of the target block to which transaction Tx1 belongs is k+2, node 1 can either re-execute the multiple transactions included in block k+1 or query the historical data cached in its memory to redistribute the storage request W2 to m storage nodes to update the shard data stored by each of the m storage nodes to block height k+1. The aforementioned historical data may be, for example, a storage request that was successfully sent to storage service 1 to update the shard data stored by each of the m storage nodes to block height k+1, or the execution results of multiple transactions belonging to the k+1th block that generated the storage request W2.

[0060] Finally, in step S48, node 1 re-executes transaction Tx1.

[0061] Since in step S47, all m storage nodes of storage service 1 have updated their respective stored shard data to the first block height, and the block corresponding to the first block height is the block preceding the block to which transaction Tx1 belongs, when node 1 re-executes transaction Tx1, it can obtain the correct response data from storage service 1 and thus re-execute transaction Tx1 correctly.

[0062] Based on the same concept as the aforementioned method embodiments, this specification also provides a storage service in a blockchain system, the blockchain system including blockchain nodes, the blockchain nodes being associated with the storage service, and the storage service including multiple storage nodes. The storage node is configured to: receive a first read request initiated by the blockchain node during the execution of a first transaction, and return response data according to the first read request, so that the blockchain node obtains the execution result of the first transaction based on the response data; receive a first storage request initiated by the blockchain node based on the execution result of the first transaction, wherein the first storage request includes a first variable value of a reference variable stored in the blockchain node; determine whether a second variable value of the reference variable stored in the storage node is the same as the first variable value, and if they are different, return an error message to the blockchain node, so that the blockchain node updates the variable values ​​of the reference variables stored in the blockchain node and the plurality of storage nodes to the same third variable value, updates the shard data stored in the plurality of storage nodes to the first block height, and re-executes the first transaction, wherein the block corresponding to the first block height in the blockchain system is the block preceding the block to which the first transaction belongs, and when the shard data stored in the plurality of storage nodes is rolled back to the same block height, the variable values ​​of the reference variables stored in the plurality of storage nodes change.

[0063] In one possible implementation, the storage service further includes a master node; wherein the master node is configured to, after a first storage node among the plurality of storage nodes restarts, obtain the block height corresponding to the shard data stored by each of the plurality of storage nodes; determine the minimum second block height among the obtained block heights; and send a data rollback request including the second block height to the plurality of storage nodes; the storage nodes are further configured to roll back their stored shard data to the second block height and change the variable value of the reference variable stored by the storage node to the second variable value.

[0064] In one possible implementation, before the first storage node restarts, the variable values ​​of the reference variables stored by the blockchain node and each of the plurality of storage nodes are all the first variable values; the storage node is further configured to change the variable values ​​of the reference variables it stores from the first variable value to a fourth variable value after it restarts; the master node is further configured to obtain the variable values ​​of the reference variables stored by each of the plurality of storage nodes; and determine the second variable value based on the obtained variable values, wherein the data rollback request also includes the second variable value.

[0065] In one possible implementation, the storage node is further configured to receive a state synchronization request from the blockchain node, the state synchronization request including the third variable value; and to update the variable values ​​of the reference variables stored in each of the plurality of storage nodes to the third variable value.

[0066] In one possible implementation, the storage service further includes a master node, configured to send the second block height corresponding to the shard data after the rollback to the blockchain node; the storage node is further configured to receive a second storage request sent by the blockchain node according to the second block height, the second storage request including the third variable value; and to update the shard data stored therein to the first block height according to the second storage request.

[0067] Based on the same concept as the foregoing method embodiments, this specification also provides a blockchain node in a blockchain system, wherein the blockchain node is associated with a storage service comprising multiple storage nodes. See also Figure 5The blockchain node includes: a transaction execution unit 51, configured to send a first read request to the storage service during the execution of a first transaction, obtain response data returned by the storage service according to the first read request, and obtain the execution result of the first transaction based on the response data; a block management unit 53, configured to send a first storage request to the storage service based on the execution result of the first transaction, wherein the first storage request includes a first variable value of a reference variable stored in the blockchain node, such that if the variable value of the reference variable stored in each of the plurality of storage nodes is different from the first variable value, the storage service returns an error message; and, in response to the error message, updates the variable value of the reference variable stored in the blockchain node and the plurality of storage nodes to the same third variable value, updates the shard data stored in each of the plurality of storage nodes to a first block height, and triggers the transaction execution unit 51 to re-execute the first transaction, wherein the block corresponding to the first block height in the blockchain system is the block preceding the block to which the first transaction belongs, and when the shard data stored in each of the plurality of storage nodes is rolled back to the same block height, the variable value of the reference variable stored in each of the plurality of storage nodes changes.

[0068] In one possible implementation, the block management unit 53 is specifically used to update the variable value of the reference variable stored in the blockchain node to a third variable value; and to send a state synchronization request to the storage service, the state synchronization request including the third variable value, so that the plurality of storage nodes update the variable value of the reference variable stored in their respective storage nodes to the third variable value.

[0069] In one possible implementation, the block management unit 53 is further configured to obtain the second block height from the storage service; wherein, the block management unit is specifically configured to send a second storage request to the storage service according to the second block height, the second storage request including the third variable value, so that the plurality of storage nodes update their respective stored shard data to the first block height.

[0070] This specification also provides a computer-readable storage medium storing a computer program that, when executed in a computer, causes the computer to perform the various method steps executed by node 1 or storage service 1 in the aforementioned method embodiments.

[0071] In the 1990s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the methodology). However, with technological advancements, many methodological improvements today can be considered direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved methodology into the hardware circuit. Therefore, it cannot be said that a methodological improvement cannot be implemented using hardware physical modules. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic function is determined by the user programming the device. Designers can program and "integrate" a digital system onto a PLD themselves, without needing chip manufacturers to design and manufacture dedicated integrated circuit chips. Furthermore, nowadays, instead of manually manufacturing integrated circuit chips, this programming is mostly implemented using "logic compiler" software. Similar to the software compiler used in program development, the original code before compilation must be written in a specific programming language, called a Hardware Description Language (HDL). There are many HDLs, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, and RHDL (Ruby Hardware Description Language). Currently, the most commonly used are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should understand that by simply performing some logic programming on the method flow using one of these hardware description languages ​​and programming it into an integrated circuit, the hardware circuit implementing the logical method flow can be easily obtained.

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

[0073] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or physical entities, or by products with certain functions. A typical implementation device is a server system. Of course, this application does not exclude the possibility that, with the future development of computer technology, the computer implementing the functions of the above embodiments can be, for example, a personal computer, a laptop computer, an in-vehicle human-machine interaction device, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or any combination of these devices.

[0074] While one or more embodiments of this specification provide the operational steps of the methods described in the embodiments or flowcharts, more or fewer operational steps may be included based on conventional or non-inventive means. The order of steps listed in the embodiments is merely one possible order of execution among many steps and does not represent the only possible order. In actual device or end product execution, the methods shown in the embodiments or drawings may be executed sequentially or in parallel (e.g., in a parallel processor or multi-threaded processing environment, or even a distributed data processing environment). The terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, product, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, product, or apparatus. Without further limitations, the presence of other identical or equivalent elements in the process, method, product, or apparatus that includes the elements is not excluded. For example, the use of terms such as "first," "second," etc., is to denote names and does not indicate any particular order.

[0075] For ease of description, the above devices are described in terms of function, divided into various modules. Of course, when implementing one or more of these specifications, the functions of each module can be implemented in one or more software and / or hardware components, or a module that performs the same function can be implemented by a combination of multiple sub-modules or sub-units. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection between devices or units, and may be electrical, mechanical, or other forms.

[0076] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0077] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0078] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0079] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0080] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0081] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, 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 technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage, graphene storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

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

[0083] One or more embodiments of this specification can be described in the general context of computer-executable instructions, such as program modules, that are executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a particular task or implement a particular abstract data type. One or more embodiments of this specification can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.

[0084] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, system embodiments are basically similar to method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments. In the description of this specification, the terms "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this specification. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described can be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification and the features of different embodiments or examples.

[0085] The above description is merely an embodiment of one or more embodiments of this specification and is not intended to limit the scope of these embodiments. Various modifications and variations can be made to these embodiments by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this specification should be included within the scope of the claims.

Claims

1. A transaction execution method in a blockchain system, the blockchain system including blockchain nodes, the blockchain nodes being associated with a storage service system comprising multiple storage nodes, the method being applied to the storage service system, the method comprising: The system receives a first read request initiated by the blockchain node during the execution of a first transaction, and returns response data based on the first read request, so that the blockchain node obtains the execution result of the first transaction based on the response data. Receive a first storage request initiated by the blockchain node based on the execution result of the first transaction, wherein the first storage request includes a first variable value of the reference variable stored in the blockchain node; The system determines whether the second variable value of the reference variable stored in the storage node is the same as the first variable value. If they are different, it returns an error message to the blockchain node, causing the blockchain node to update the variable values ​​of the reference variable stored in the blockchain node and the plurality of storage nodes to the same third variable value. It also updates the shard data stored in the plurality of storage nodes to the first block height and re-executes the first transaction. In the blockchain system, the block corresponding to the first block height is the block preceding the block to which the first transaction belongs. When the shard data stored in the plurality of storage nodes is rolled back to the same block height, the variable values ​​of the reference variables stored in the plurality of storage nodes are changed to the same variable value, and this same variable value is different from the variable value of the reference variable stored in the blockchain node.

2. The method according to claim 1, wherein the storage service system further includes a master node; the method further includes: After the first storage node among the plurality of storage nodes restarts, the master node obtains the block height corresponding to the shard data stored by each of the plurality of storage nodes. The master node determines the second block height that is the smallest among all the block heights it obtains; The master node sends a data rollback request, including the height of the second block, to the plurality of storage nodes; The storage node rolls back its stored fragment data to the second block height and changes the variable value of the reference variable stored by the storage node to the second variable value.

3. The method according to claim 2, wherein before the first storage node restarts, the variable values ​​of the reference variables stored in the blockchain node and each of the plurality of storage nodes are the first variable values; wherein, The method further includes: After the first storage node restarts, the variable value of the reference variable stored in the first storage node is changed from the first variable value to the fourth variable value; The master node obtains the variable values ​​of the reference variables stored by each of the plurality of storage nodes; The master node determines the second variable value based on the various variable values ​​it obtains, and the data rollback request also includes the second variable value.

4. The method according to any one of claims 1-3, further comprising: Receive a state synchronization request from the blockchain node, the state synchronization request including the value of the third variable; The variable values ​​of the reference variables stored in each of the plurality of storage nodes are updated to the third variable value.

5. The method according to claim 4, further comprising: Send the second block height corresponding to the sharded data after the rollback to the blockchain node; Receive from the blockchain node a second storage request sent by it according to the second block height, the second storage request including the third variable value; The fragmented data stored by each of the plurality of storage nodes is updated to the first block height according to the second storage request.

6. A transaction execution method in a blockchain system, the blockchain system including blockchain nodes, the blockchain nodes being associated with a storage service system comprising multiple storage nodes, the method being applied to the blockchain nodes, the method comprising: During the execution of the first transaction, a first read request is sent to the storage service system, response data is obtained from the storage service system based on the first read request, and the execution result of the first transaction is obtained based on the response data; Based on the execution result of the first transaction, a first storage request is sent to the storage service system. The first storage request includes a first variable value of a reference variable stored in the blockchain node. If the variable value of the reference variable stored in each of the multiple storage nodes is different from the first variable value, the storage service system returns an error message. In response to the error message, the variable values ​​of the reference variables stored in the blockchain node and the plurality of storage nodes are updated to the same third variable value. The shard data stored in the plurality of storage nodes is updated to the first block height, and the first transaction is re-executed. In the blockchain system, the block corresponding to the first block height is the block preceding the block to which the first transaction belongs. When the shard data stored in the plurality of storage nodes is rolled back to the same block height, the variable values ​​of the reference variables stored in the plurality of storage nodes are changed to the same variable value, and the same variable value is different from the variable value of the reference variable stored in the blockchain node.

7. The method of claim 6, wherein the updating the variable values of the reference variable stored respectively in the blockchain node and the plurality of storage nodes to the same third variable value comprises: Update the value of the reference variable stored in the blockchain node to the value of the third variable; A state synchronization request is sent to the storage service system, the state synchronization request including the third variable value, so that the plurality of storage nodes update the variable values ​​of the reference variables stored in their respective storage nodes to the third variable value.

8. The method of claim 6, further comprising: Obtain the second block height corresponding to the sharded data after the rollback from the storage service system; Specifically, updating the shard data stored in each of the plurality of storage nodes to the first block height includes: sending a second storage request to the storage service system according to the second block height, wherein the second storage request includes the third variable value, so that the plurality of storage nodes update their respective shard data to the first block height.

9. A storage service system in a blockchain system, the blockchain system including blockchain nodes associated with the storage service system, the storage service system including multiple storage nodes, the storage nodes being used to perform: The system receives a first read request initiated by the blockchain node during the execution of the first transaction, and returns response data based on the first read request, so that the blockchain node obtains the execution result of the first transaction based on the response data. Receive a first storage request initiated by the blockchain node based on the execution result of the first transaction, wherein the first storage request includes a first variable value of the reference variable stored in the blockchain node; The system determines whether the second variable value of the reference variable stored in the storage node is the same as the first variable value. If they are different, it returns an error message to the blockchain node, causing the blockchain node to update the variable values ​​of the reference variable stored in the blockchain node and the plurality of storage nodes to the same third variable value. It also updates the shard data stored in the plurality of storage nodes to the first block height and re-executes the first transaction. In the blockchain system, the block corresponding to the first block height is the block preceding the block to which the first transaction belongs. When the shard data stored in the plurality of storage nodes is rolled back to the same block height, the variable values ​​of the reference variables stored in the plurality of storage nodes are changed to the same variable value, and this same variable value is different from the variable value of the reference variable stored in the blockchain node.

10. The storage service system according to claim 9, wherein the storage service system further includes a master node; wherein, The master node is used to obtain the block height corresponding to the shard data stored by each of the plurality of storage nodes after the first storage node among the plurality of storage nodes is restarted; Determine the second block height, which is the smallest among the obtained block heights; send a data rollback request, including the second block height, to the plurality of storage nodes; The storage node is also configured to roll back the sharded data it stores to the second block height, and change the variable value of the reference variable stored by the storage node to the second variable value.

11. The storage service system according to claim 10, wherein before the first storage node restarts, the variable values ​​of the reference variables stored in the blockchain node and each of the plurality of storage nodes are the first variable values; wherein, The storage node is also configured to change the value of the reference variable it stores from the first variable value to the fourth variable value after it restarts; The master node is also used to obtain the variable values ​​of the reference variables stored by each of the plurality of storage nodes; The second variable value is determined based on the various variable values ​​obtained therefrom, and the data rollback request also includes the second variable value.

12. The storage service system according to any one of claims 9-11, wherein the storage node is further configured to receive a state synchronization request from the blockchain node, the state synchronization request including the third variable value; and to update the variable value of the reference variable stored in each of the plurality of storage nodes to the third variable value.

13. The storage service system according to claim 12, further comprising a master node, configured to send the second block height corresponding to the sharded data after the rollback to the blockchain node; the storage node is further configured to receive a second storage request sent by the blockchain node according to the second block height, the second storage request including the third variable value; and to update the sharded data stored therein to the first block height according to the second storage request.

14. A blockchain node in a blockchain system, the blockchain node being associated with a storage service system comprising multiple storage nodes, the blockchain node comprising: The transaction execution unit is used to send a first read request to the storage service system during the execution of the first transaction, obtain response data returned by the storage service system according to the first read request, and obtain the execution result of the first transaction according to the response data; The block management unit is used to send a first storage request to the storage service system based on the execution result of the first transaction. The first storage request includes a first variable value of a reference variable stored in the blockchain node, so that if the variable value of the reference variable stored in each of the multiple storage nodes is different from the first variable value, the storage service system returns an error message. In response to the error message, the variable values ​​of the reference variables stored in the blockchain node and the plurality of storage nodes are updated to the same third variable value. The shard data stored in the plurality of storage nodes is updated to the first block height, and the transaction execution unit is triggered to re-execute the first transaction. In the blockchain system, the block corresponding to the first block height is the block preceding the block to which the first transaction belongs. When the shard data stored in the plurality of storage nodes is rolled back to the same block height, the variable values ​​of the reference variables stored in the plurality of storage nodes are changed to the same variable value, and the same variable value is different from the variable value of the reference variable stored in the blockchain node.

15. The blockchain node according to claim 14, wherein the block management unit is specifically configured to update the variable value of the reference variable stored in the blockchain node to a third variable value; and send a state synchronization request to the storage service system, wherein the state synchronization request includes the third variable value, so that the plurality of storage nodes update the variable value of the reference variable stored in each of them to the third variable value. 16.The blockchain node of claim 14, wherein the block management unit is further configured to obtain, from the storage service system, a second block height corresponding to the sharded data after the rollback occurs; and The block management unit is specifically used to send a second storage request to the storage service system according to the second block height. The second storage request includes the third variable value, so that the multiple storage nodes update their respective stored shard data to the first block height.

17. A computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to perform the method of any one of claims 1-8.

Citation Information

Patent Citations

  • Blockchain data recovery method and device, equipment and medium

    CN111651300A

  • Method and device for executing transaction in block chain node

    CN113744064A