A data processing method and device based on a smart contract and related equipment

CN116680729BActive Publication Date: 2026-08-18TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210169906.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-23
Publication Date
2026-08-18
Estimated Expiration
2042-02-23

AI Technical Summary

Technical Problem

在调用智能合约执行交易的过程中,需要读取或变更MPT中存储的状态数据,此时,需要使用MPT中的树节点对应的键值作为状态数据的索引,而获取MPT中树节点对应的键值又需要调用额外的智能合约进行一系列处理才能得到,因此在对MPT中存储的状态数据进行变更或读取时,操作繁琐,效率低

Benefits of technology

[0015] Accordingly, this application also provides a computer program, which includes computer instructions stored in a computer-readable storage medium. The processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the data processing method based on smart contracts provided in this application.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116680729B_ABST
    Figure CN116680729B_ABST
Patent Text Reader

Abstract

A data processing method and device based on a smart contract and related equipment can be applied to various fields or scenarios such as cloud technology, artificial intelligence, block chain, Internet of Vehicles, intelligent transportation, smart home, etc. The method comprises: in response to a data operation instruction about state data of a target smart contract, determining a key object to be operated indicated by the data operation instruction; if the data operation instruction is a first operation instruction, executing the data operation indicated by the data operation instruction on a value object corresponding to the key object to be operated in a target description file; if the data operation instruction is a second operation instruction, determining a reference value corresponding to the key object to be operated indicated by the data operation instruction, and recording the key object to be operated and the reference value in the target description file. By adopting the embodiments of the present application, the efficiency of data operation on the state data of the target smart contract can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a data processing method based on smart contracts, a data processing device based on smart contracts, a computer device, a computer-readable storage medium, and a computer program product. Background Technology

[0002] Currently, nodes in blockchain systems often use Merkle PatriciaTree (MPT) to store the state data of smart contracts, such as bills, account balances, and logistics information. During the execution of transactions by calling smart contracts, it is necessary to read or modify the state data stored in the MPT. This requires using the key-value pairs corresponding to the tree nodes in the MPT as indexes for the state data. However, retrieving these key-value pairs requires calling additional smart contracts for a series of processing steps. Therefore, modifying or reading the state data stored in the MPT is cumbersome and inefficient. Summary of the Invention

[0003] This application provides a data processing method, apparatus, and related equipment based on smart contracts, which can improve the efficiency of data operations on the state data of a target smart contract.

[0004] On one hand, embodiments of this application provide a data processing method based on smart contracts, wherein a target description file corresponding to a target smart contract is stored in a specified storage space. The target description file is constructed based on the state data of the target smart contract. The target description file includes one or more key-value combinations, each key-value combination including a key object and a value object. The key object and the value object are determined based on the state data. The method includes:

[0005] The processing unit is configured to, in response to a data operation instruction regarding the state data of the target smart contract, determine the key object to be operated as indicated by the data operation instruction;

[0006] The processing unit is further configured to, if the data operation instruction is a first operation instruction, execute the data operation indicated by the data operation instruction on the value object corresponding to the key object to be operated on in the target description file; wherein, the first operation instruction includes one or more of a data read instruction, a data update instruction, and a data delete instruction;

[0007] The processing unit is further configured to, if the data operation instruction is a second operation instruction, determine the reference value corresponding to the key object to be operated indicated by the data operation instruction, and associate and record the key object to be operated and the reference value in the target description file; wherein, the second operation instruction includes a data insertion instruction.

[0008] On one hand, embodiments of this application provide a data processing apparatus based on smart contracts, wherein a target description file corresponding to a target smart contract is stored in a designated storage space. The target description file is constructed based on the state data of the target smart contract. The target description file includes one or more key-value combinations, each key-value combination including a key object and a value object. The key object and the value object are determined based on the state data. The apparatus includes:

[0009] The processing unit is configured to, in response to a data operation instruction regarding the state data of the target smart contract, determine the key object to be operated as indicated by the data operation instruction;

[0010] The processing unit is further configured to, if the data operation instruction is a first operation instruction, execute the data operation indicated by the data operation instruction on the value object corresponding to the key object to be operated on in the target description file; wherein, the first operation instruction includes one or more of a data read instruction, a data update instruction, and a data delete instruction;

[0011] The processing unit is further configured to, if the data operation instruction is a second operation instruction, determine the reference value corresponding to the key object to be operated indicated by the data operation instruction, and associate and record the key object to be operated and the reference value in the target description file; wherein, the second operation instruction includes a data insertion instruction.

[0012] On one hand, embodiments of this application provide a computer device, which includes a processor, a communication interface, and a memory. The processor, the communication interface, and the memory are interconnected. The memory stores a computer program, and the processor is used to call the computer program to execute a data processing method based on a smart contract, which is one of the above possible implementations.

[0013] On one hand, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements a smart contract-based data processing method of any possible implementation.

[0014] Accordingly, this application also provides a computer program product, which includes a computer program or computer instructions. The computer program or computer instructions are executed by a processor to implement the steps of the data processing method based on smart contracts provided in this application.

[0015] Accordingly, this application also provides a computer program, which includes computer instructions stored in a computer-readable storage medium. The processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the data processing method based on smart contracts provided in this application.

[0016] In this embodiment, in response to a data operation instruction regarding the state data of the target smart contract, the key object to be operated indicated by the data operation instruction is determined. When the data operation instruction is a first operation instruction, the data operation indicated by the data operation instruction is executed on the value object corresponding to the key object to be operated on in the target description file. When the data operation instruction is a second operation instruction, the reference value corresponding to the key object to be operated on indicated by the data operation instruction is determined, and the key object to be operated on and the reference value are associated and recorded in the target description file. By using the above method, the state data of the target smart contract is stored using a specific type of target description file. When data operations are required on the state data of the target smart contract, the target description file can be processed directly without additional calls to the smart contract for processing. The operation is simple and efficient. Attached Figure Description

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

[0018] Figure 1 This application provides a schematic diagram of the structure of a distributed system applied to a blockchain system.

[0019] Figure 2 A schematic diagram of a block structure provided in an embodiment of this application;

[0020] Figure 3 A flowchart illustrating a data processing method based on smart contracts provided in this application embodiment. Figure 1 ;

[0021] Figure 4A flowchart illustrating a data processing method based on smart contracts provided in this application embodiment. Figure 2 ;

[0022] Figure 5 A flowchart illustrating a data processing method based on smart contracts provided in this application embodiment. Figure 3 ;

[0023] Figure 6 A flowchart illustrating a data processing method based on smart contracts provided in this application embodiment. Figure 4 ;

[0024] Figure 7 A flowchart illustrating a data processing method based on smart contracts provided in this application embodiment. Figure 5 ;

[0025] Figure 8 A schematic diagram of the structure of a data processing device based on smart contracts provided in this application embodiment;

[0026] Figure 9 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation

[0027] The technical methods in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0028] It should be noted that the terms "first," "second," etc., used in the embodiments of this application are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, technical features defined with "first," "second," etc., may explicitly or implicitly include at least one of those features.

[0029] The blockchain system involved in this application embodiment can be a distributed system formed by connecting clients and multiple nodes (any form of computing device in the network, such as servers and user terminals) through network communication.

[0030] Taking a distributed system as an example, see blockchain system. Figure 1 , Figure 1This is a schematic diagram illustrating the structure of the distributed system 100 provided in this application embodiment applied to a blockchain system. It consists of multiple nodes (any form of computing device connected to the network, such as servers or user terminals) and clients. These nodes form a peer-to-peer (P2P) network. The P2P protocol is an application layer protocol running on top of the Transmission Control Protocol (TCP). In the distributed system, any machine, such as a server or terminal, can join and become a node. A node includes a hardware layer, a middleware layer, an operating system layer, and an application layer.

[0031] See Figure 1 The functions of each node in the blockchain system shown include:

[0032] 1) Routing: A basic function of nodes used to support communication between nodes.

[0033] 2) Applications are deployed in the blockchain to implement specific business needs. They record data related to the implementation of functions to form record data, carry digital signatures in the record data to indicate the source of the task data, and send the record data to other nodes in the blockchain system. When other nodes successfully verify the source and integrity of the record data, they add the record data to a temporary block.

[0034] For example, the business functions implemented by the application include: ① A wallet, used to provide the function of trading digital assets, including initiating a transaction (i.e., sending the transaction record of the current transaction to other nodes in the blockchain system; after successful verification by other nodes, as a response acknowledging the validity of the transaction, the transaction record data is stored in a temporary block of the blockchain). Of course, the wallet also supports querying the remaining digital assets in the digital asset address. Here, "transaction" is equivalent to the computer term "transaction," and a transaction includes operations that need to be submitted to the blockchain system for execution. It does not only refer to transactions in a business context. Given that the term "transaction" is conventionally used in blockchain technology, this application embodiment follows this convention. ② A shared ledger, used to provide account data. The functions of storage, querying, and modification send the records of operations on the ledger data to other nodes in the blockchain system. After other nodes verify the validity, they store the records in a temporary block as a response acknowledging the validity of the ledger data. They can also send confirmation to the node that initiated the operation. ③ Smart contracts are computerized protocols that can execute the terms of a contract. They are implemented through code deployed on a shared ledger that executes when certain conditions are met. Based on actual business needs, the code is used to complete automated transactions, such as querying the logistics status of goods purchased by a buyer and transferring the buyer's digital assets to the merchant's address after the buyer signs for the goods. Of course, smart contracts are not limited to executing contracts for transactions; they can also execute contracts for processing received information.

[0035] 3) A blockchain consists of a series of blocks that are sequentially generated. Once a new block is added to the blockchain, it will not be removed. The blocks contain the data submitted by the nodes in the blockchain system.

[0036] See Figure 2 , Figure 2 This is a schematic diagram of the block structure provided in this application embodiment. Each block includes the hash value of the transaction records stored in this block (the hash value of this block) and the hash value of the previous block. The blocks are connected through their hash values ​​to form a blockchain. Additionally, the block may include information such as a timestamp when it was generated. A blockchain is essentially a decentralized database, a chain of data blocks linked together using cryptographic methods. Each data block contains relevant information used to verify the validity of the information (anti-counterfeiting) and to generate the next block.

[0037] The specific implementation of the data processing method based on smart contracts provided in the embodiments of this application will be described in detail below.

[0038] Please see Figure 3 , Figure 3A flowchart illustrating a data processing method based on smart contracts provided in this application embodiment. Figure 1 This method is applied to any node in a blockchain system. This node can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. Alternatively, this node can be a terminal device such as a smartphone, tablet, laptop, desktop computer, smart voice interaction device, smart home appliance, or in-vehicle terminal. The method includes the following steps S301-S303:

[0039] S301. In response to a data manipulation instruction regarding the state data of the target smart contract, determine the key object to be manipulated as indicated by the data manipulation instruction.

[0040] Each target smart contract has a corresponding target description file, which is constructed based on the target smart contract's state data. Specifically, the target description file includes one or more key-value pairs. Each key-value pair includes a key object and a value object, which are determined based on the target smart contract's state data. That is, the key object is the attribute name of the target smart contract's state data, and the value object is the attribute value of the target smart contract's state data. For example, the key object in a key-value pair could be the account balance of account A, and the corresponding value object could be the amount of assets corresponding to the account balance of account A.

[0041] The state data of the target smart contract is generated when the target smart contract executes a transaction. For a single transaction, the target smart contract can initiate one or more data operation instructions. For example, when the target smart contract transfers digital assets from account A to account B's address, it can initiate data read instruction 1 for account A's account balance and data read instruction 2 for account B's account balance. In this case, the key object to be operated on by data read instruction 1 is account A's account balance, and the key object to be operated on by data read instruction 2 is account B's account balance. Based on the read asset amounts of accounts A and B, and the amount of assets to be transferred from account A, the final asset amounts of accounts A and B are determined. Using the final asset amounts of account A, data update instruction 1 for account A's account balance is initiated, and data update instruction 2 for account B's account balance is initiated. In this case, the key object to be operated on by data update instruction 1 is account A's account balance, and the key object to be operated on by data update instruction 2 is account B's account balance.

[0042] The target description file corresponding to the target smart contract is stored in a specified storage space, which can be memory. By storing the target description file in memory, data operations on the data in the target description file can be performed much faster compared to a disk database.

[0043] S302. If the data operation instruction is the first operation instruction, then for the value object corresponding to the key object to be operated on in the target description file, the data operation indicated by the data operation instruction is executed; wherein, the first operation instruction includes one or more of the following: data read instruction, data update instruction, and data delete instruction.

[0044] In one implementation, when the data operation instruction is the first operation instruction, it can be checked whether the key object to be operated on is contained in the target description file. If the key object to be operated on is not contained in the target description file, an error message is returned; if the key object to be operated on is contained in the target description file, the data operation indicated by the data operation instruction is executed on the value object corresponding to the key object to be operated on in the target description file.

[0045] In one embodiment, when the data operation instruction is a first operation instruction and the first operation instruction is a data read instruction, the data operation indicated by the data operation instruction is performed on the value object corresponding to the key object to be operated on in the target description file, including: reading the value object corresponding to the key object to be operated on from the target description file. For example, when the key object to be operated on is the account balance of account B, the asset amount corresponding to the account balance of account B is read as 100 from the target description file.

[0046] In one embodiment, when the data operation instruction is a first operation instruction and the first operation instruction is a data update instruction, the data operation indicated by the data operation instruction is executed for the value object corresponding to the key object to be operated on in the target description file. This includes: obtaining the update value corresponding to the key object to be operated on as indicated by the data operation instruction. The update value corresponding to the key object to be operated on can be carried by the data operation instruction, and replacing the value object corresponding to the key object to be operated on in the target description file with the update value. For example, if the asset amount corresponding to the account balance of account B in the target description file is 100, and the update value is 50, then the asset amount corresponding to the account balance of account B in the target description file will be updated from 100 to 50.

[0047] In one implementation, when the data operation instruction is a first operation instruction, and the first operation instruction is a data deletion instruction, the data operation indicated by the data operation instruction is executed on the value object corresponding to the key object to be operated on in the target description file, including: deleting the value object corresponding to the key object to be operated on in the target description file. In feasible embodiments, the key-value combination consisting of the key object to be operated on and the value object corresponding to the key object to be operated on can also be deleted from the target description file.

[0048] This embodiment allows the key object to be used directly as an index to the value object for data manipulation, thereby improving the efficiency of data operations.

[0049] S303. If the data operation instruction is a second operation instruction, then determine the reference value corresponding to the key object to be operated indicated by the data operation instruction, and associate and record the key object to be operated and the reference value in the target description file; wherein, the second operation instruction includes a data insertion instruction.

[0050] In one embodiment, when the data operation instruction is a second operation instruction, and the second operation instruction is a data insertion instruction, a reference value corresponding to the key object to be operated indicated by the data operation instruction is determined, and the key object to be operated and the reference value corresponding to the key object to be operated are associated and recorded in the target description file. For example, when account C is created for the first time, and account C needs to conduct transactions related to digital assets, the account balance of account C and the asset quantity corresponding to the account balance of account C can be associated and recorded in the target description file first. When account C needs to conduct transfer-related transactions later, data reading or data updating processing is performed on the asset quantity corresponding to the account balance of account C in the target description file.

[0051] In this embodiment, in response to a data operation instruction regarding the state data of the target smart contract, the key object to be operated indicated by the data operation instruction is determined. When the data operation instruction is a first operation instruction, the data operation indicated by the data operation instruction is executed on the value object corresponding to the key object to be operated on in the target description file. When the data operation instruction is a second operation instruction, the reference value corresponding to the key object to be operated on indicated by the data operation instruction is determined, and the key object to be operated on and the reference value are associated and recorded in the target description file. By using the above method, the state data of the target smart contract is stored using a specific type of target description file. When data operations are required on the state data of the target smart contract, the target description file can be processed directly without additional calls to the smart contract for processing. The operation is simple and efficient.

[0052] Please see Figure 4 , Figure 4 A flowchart illustrating a data processing method based on smart contracts provided in this application embodiment. Figure 2 This method is applied to any node in a blockchain system and includes the following steps S401-S405:

[0053] S401. In response to a data manipulation instruction regarding the state data of the target smart contract, determine the key object to be manipulated as indicated by the data manipulation instruction.

[0054] Each target smart contract corresponds to a target description file, which is constructed by encapsulating the state data of the target smart contract using a structured representation language. This structured representation language can be JSON (JavaScript Object Notation), YAML (YAML ain't markup language), etc. JSON is a lightweight data exchange format that uses a text format completely independent of programming languages ​​to store and represent data. It is easy for humans to read and write, and also easy for machines to parse and generate. YAML is a markup language with powerful expressive capabilities. For example, the state data of the target smart contract includes: in bank A, the asset amounts corresponding to the account balances of account A and account B are 10 and 20 respectively; in bank B, the asset amounts corresponding to the account balances of account A and account B are 30 and 40 respectively. If JSON is used, it can be represented in the target description file as follows:

[0055]

[0056] At this point, when responding to a data operation instruction regarding the state data of the target smart contract, it is necessary to determine the operation object corresponding to the data operation instruction. This operation object can be one or more. When there is only one operation object, it is used as the key object to be operated on. When there are multiple operation objects, the hierarchical relationship between them is determined, and the multiple operation objects are cascaded according to the hierarchical relationship. The key object to be operated on, as indicated by the data operation instruction, is determined based on the cascading result. For example, if the data operation instruction is: "Update the account balance of account A in bank A", then there are multiple operation objects: bank A, account A, and account balance. The hierarchical relationship between these operation objects, from top to bottom, is: bank A, account A, and account balance. They can be cascaded using ":", resulting in the cascading result: "bank A: account A: account balance". "bank A: account A: account balance" is the key object to be operated on.

[0057] In one embodiment, the key object to be operated on can be determined using the following equations (1) and (2).

[0058] FlatKey=JsonDriverTransform(TargetKey) (1)

[0059] JsonDriverTransform(x)=Join(“:”,[x.Object,x.SubObject,...,x.Key])(2)

[0060] Here, FlatKey represents the key object to be operated on, TargetKey represents the key to which the data operation instruction in the target smart contract is targeted, and JsonDriverTransform represents converting TargetKey to FlatKey. TargetKey indicates one or more operation objects, x.Object, x.SubObject,...,x.Key are the operation objects indicated by TargetKey, and x.Object, x.SubObject,...,x.Key are sorted according to the hierarchical relationship, that is, x.Object represents the outermost object, x.SubObject represents the child object relative to the parent object, and x.Key represents the innermost object. In addition, x.SubObject can also be represented by array subscripts (without limit on nesting level).

[0061] As can be seen, the name and hierarchy of the operation object indicated by the key to the data operation instruction in the target smart contract can be saved through the structure representation language, so that the target description file can be directly read and written by external applications or by humans without the need for additional processing by the smart contract.

[0062] S402. If the data operation instruction is the first operation instruction, then for the value object corresponding to the key object to be operated on in the target description file, the data operation indicated by the data operation instruction is executed; wherein, the first operation instruction includes one or more of the following: data read instruction, data update instruction, and data delete instruction.

[0063] In one implementation, when the data operation instruction is the first operation instruction, and the first operation instruction is a data read instruction, the data operation indicated by the data operation instruction is executed for the value object corresponding to the key object to be operated on in the target description file. This includes reading the value object corresponding to the key object to be operated on from the target description file. For example, when the key object to be operated on is "Bank A: Account A: Account Balance", then Bank A, Account A, and Account Balance are searched sequentially from the target description file, ultimately obtaining the asset amount corresponding to the account balance of Account A in Bank A as 10.

[0064] In one embodiment, when the data operation instruction is a first operation instruction and the first operation instruction is a data read instruction, the data operation indicated by the data operation instruction is executed for the value object corresponding to the key object to be operated on in the target description file. This includes: obtaining the updated value corresponding to the key object to be operated on as indicated by the data operation instruction. The updated value corresponding to the key object to be operated on can be carried by the data operation instruction, and replacing the value object corresponding to the key object to be operated on in the target description file with the updated value. For example, when the key object to be operated on is "Bank A: Account A: Account Balance", then Bank A, Account A, and Account Balance are searched sequentially from the target description file, and finally the asset amount 10 corresponding to the account balance of Account A in Bank A is changed to the updated value 50.

[0065] In feasible embodiments, when the data operation instruction is a first operation instruction, and the first operation instruction is a data deletion instruction, the data operation indicated by the data operation instruction is executed on the value object corresponding to the key object to be operated on in the target description file, including: deleting the value object corresponding to the key object to be operated on in the target description file. For example, when the key object to be operated on is "Bank A: Account A: Account Balance", then Bank A, Account A, and Account Balance are searched sequentially in the target description file, and finally the account balance 10 of Account A in Bank A can be changed to null. In feasible embodiments, the key-value combination consisting of the key object to be operated on and the value object corresponding to the key object to be operated on can also be deleted from the target description file.

[0066] S403. If the data operation instruction is a second operation instruction, then determine the reference value corresponding to the key object to be operated indicated by the data operation instruction, and associate and record the key object to be operated and the reference value in the target description file; wherein, the second operation instruction includes a data insertion instruction.

[0067] In one embodiment, when the data operation instruction is a second operation instruction, and the second operation instruction is a data insertion instruction, a reference value corresponding to the key object to be operated indicated by the data operation instruction is determined, and the key object to be operated and the reference value corresponding to the key object to be operated are associated and recorded in the target description file. During the association recording, it can be determined whether the key object to be operated has a common key object in the target description file. For example, if the key object to be operated is "Bank A: Account C: Account Balance", then there is a common key object: Bank A. A structure indicating the key object to be operated can be created using the common key object based on the rules of the structure representation language, and then the reference value corresponding to the key object to be operated is used as the value object corresponding to the key object to be operated. If no common key object exists, then a structure indicating the key object to be operated is directly created in the target description file based on the rules of the structure representation language, and then the reference value corresponding to the key object to be operated is used as the value object corresponding to the key object to be operated.

[0068] S404. Determine the state root iteration data based on the key object to be operated on and the type of data operation instruction.

[0069] When a data manipulation instruction is any of the following types: data update, data insertion, or data deletion, the data in the target description file will change, and the state root of the target smart contract will also change. First, the state root iteration data needs to be determined based on the key object to be operated on and the type of data manipulation instruction.

[0070] In one implementation, when the type of data operation instruction is a data deletion instruction, the state root iteration data can be determined according to the following equation (3).

[0071] content(OP)=JOIN(“:”,[-1,FlatKey]) (3)

[0072] Where content(OP) represents the state root iteration data and FlatKey represents the key object to be operated on, the final state root iteration data is "-1:FlatKey".

[0073] In another implementation, when the data operation instruction is a data insertion instruction or a data update instruction, it is also necessary to obtain the target value corresponding to the key object to be operated indicated by the data operation instruction. When the data operation instruction is a data insertion instruction, the target value corresponding to the key object to be operated is the reference value corresponding to the key object to be operated mentioned above. When the data operation instruction is a data update instruction, the target value corresponding to the key object to be operated is the update value corresponding to the key object to be operated mentioned above. Further, the state root iteration data is determined according to the target value corresponding to the key object to be operated, the key object to be operated, and the type of the data operation instruction.

[0074] In one embodiment, when the data operation instruction is a data insertion instruction, the state root iteration data is determined according to the target value corresponding to the key object to be operated, the key object to be operated, and the type of the data operation instruction. This can be achieved by the following equation (4).

[0075] content(OP)=JOIN(“:”,[1,(FlatKey,V)]) (4)

[0076] Where V represents the target value corresponding to the key object to be operated on, and the final state root iteration data is "1:FlatKey:V".

[0077] In one embodiment, when the data operation instruction is a data update instruction, the state root iteration data is determined based on the target value corresponding to the key object to be operated on, the key object to be operated on, and the type of the data operation instruction. This can be achieved using the following equation (5). The final state root iteration data is "0:FlatKey:V".

[0078] content(OP)=JOIN(“:”,[0,(FlatKey,V)]) (5)

[0079] S405. Determine the target state root of the target smart contract based on the state root iteration data and the reference state root of the target smart contract.

[0080] The reference state root of the target smart contract is either the initial state root or the state root generated after the last data operation on the data in the target description file. The initial state root can be obtained by hashing an empty string, as shown in equation (6) below. Specifically, the initial state root StateRoot0 can be obtained by hashing an empty string using the MD5 algorithm (Message Digest Algorithm 5).

[0081] StateRoot0 = MD5(“”) (6)

[0082] In one embodiment, when the data operation instruction is any one of the data update instruction, data deletion instruction, and data insertion instruction, the target state root of the target smart contract is determined based on the state root iteration data and the reference state root of the target smart contract, which can be achieved according to the following formula (7).

[0083] StateRoot i =MD5(StateRoot) i-1 ,content(OP i (7)

[0084] Among them, StateRoot i StateRoot represents the target state root of the target smart contract. i-1 This represents the initial state root or the state root generated after the last data operation on the target description file, where i represents the number of data operations.

[0085] In one feasible implementation, when the type of data operation instruction is a data read instruction, the data in the target description file will not change, and it can be determined that the state root iteration data does not exist. Then, based on the state root iteration data and the reference state root of the target smart contract, the target state root of the target smart contract is determined, including: if it is determined that the state root iteration data does not exist, the reference state root of the target smart contract is directly used as the target state root of the target smart contract.

[0086] Understandably, every time the data in the target description file changes, the state root of the target smart contract will be iterated based on the previous state root. Nodes in the blockchain system that have undergone the same data operation process will obtain the same state root of the target smart contract. In this way, different nodes can verify the consistency of the data in the target description file by comparing whether the state roots of the target smart contract are the same.

[0087] In this embodiment, the target description file is constructed by encapsulating the state data of the target smart contract using a structured representation language. It can store the name and level of the operation object indicated by the key to the data operation instructions in the target smart contract, so that the target description file can be directly read and written by external applications or manually without the need for additional smart contract processing, thereby improving the efficiency of data processing for the state data of the target smart contract. In addition, when the data in the target description file changes, the state root of the target smart contract can be iteratively updated, so that each node in the blockchain system can use the state root of the target smart contract to perform consistency verification of the data in the target description file.

[0088] Please see Figure 5 , Figure 5A flowchart illustrating a data processing method based on smart contracts provided in this application embodiment. Figure 3 This method is applied to any node in a blockchain system and includes the following steps S501-S503:

[0089] S501. If the block height based on the blockchain determines that the backup point has been reached, then obtain the target description file from the first storage space.

[0090] The target description file corresponds to the target smart contract, which is any smart contract; that is, every smart contract has a corresponding description file. The target description file is stored in a first storage space, which can be memory. When the target description file is stored in memory, operations on the data in the target description file can be performed quickly.

[0091] The backup point can be a set block height. For example, the block height corresponding to the backup point can be set to 1N, 2N, 4N, etc., where N represents a positive integer. When the block height of the blockchain is 1N, 2N, or 4N, it is determined that the backup point has been reached. In one embodiment, when the block height of the blockchain determines that the backup point has been reached, the target description file can be obtained from the first storage space. Specifically, this means obtaining the description file corresponding to each smart contract from the first storage space, because when the backup point is reached, the state data of each smart contract needs to be persistently stored.

[0092] S502. Serialize the data in the target description file to obtain the sequence stream data corresponding to the target description file.

[0093] Serialization is the process of converting data in a target description file into a format that can be stored or transmitted. In one embodiment, if the target description file is built using the JSON language, the data in the target description file can be serialized using JSON's own serialization algorithm to obtain the corresponding serial stream data.

[0094] S503. Save the sequence stream data corresponding to the target description file to the second storage space, which is different from the first storage space.

[0095] The second storage space can be a hard disk drive, a solid-state drive, a non-volatile memory, or other storage space. The second storage space can realize the persistent storage of the sequence stream data corresponding to the target description file. Therefore, in one embodiment, the sequence stream data corresponding to the target description file can be saved to the second storage space.

[0096] In one embodiment, based on steps S501-S503, a data rollback operation can be implemented for the blockchain, including:

[0097] 1) In response to a data rollback request, determine the target backup point based on the block identifier carried in the data rollback request; wherein, the target backup point is the nearest backup point before the block height corresponding to the block identifier.

[0098] When packaging one or more transactions into a block, one or more smart contracts are invoked. Each smart contract may initiate one or more data operation instructions for a single transaction, and the state root of the corresponding smart contract is iteratively updated after each data operation instruction is processed. In one embodiment, when all transactions have been processed and the block is about to be generated, the state roots of each invoked smart contract can be obtained. The feature values ​​of the input information in the block header can be determined based on the state roots of each invoked smart contract. Specifically, the hash values ​​obtained by hashing the state roots of each invoked smart contract using the MD5 algorithm can be used as the feature values ​​of the input information in the block header.

[0099] The block header information of a block is composed of the feature values ​​of the input information, the feature values ​​of the input information of the current block, the feature values ​​of the block header of the parent block, the version number, the timestamp, and the difficulty value.

[0100] Block identifiers include the identifiers of reference blocks in the blockchain whose block header information is inconsistent. The block header information is determined based on the state root of the reference smart contract, which is the smart contract invoked when the reference block is generated. Additionally, a block identifier can also be the identifier of the block corresponding to a fork point in the blockchain. A fork point is where the blockchain splits into another chain.

[0101] 2) Obtain the sequence stream data corresponding to the target backup point from the second storage space.

[0102] The block identifier carried by the data rollback request can be used to determine the block height corresponding to that block identifier in the blockchain. This allows us to obtain the nearest backup point before the block height corresponding to the block identifier, i.e., the target backup point. The sequence stream data corresponding to the target backup point can then be obtained from the second storage space.

[0103] 3) Perform data rollback operation based on the sequence stream data corresponding to the target backup point.

[0104] In one embodiment, the data rollback operation based on the sequence stream data corresponding to the target backup point includes: first, deserializing the sequence stream data corresponding to the target backup point to obtain the description file corresponding to the target backup point; then, writing the description file corresponding to the target backup point into the first storage space; further, determining the transaction to be replayed, and performing the data rollback operation based on the transaction to be replayed and the description file corresponding to the target backup point in the first storage space.

[0105] Specifically, the transaction to be replayed can be re-verified, and then the smart contract will be called again to execute the transaction to be replayed. During the execution of the transaction, relevant data operations will be performed on the description file corresponding to the target backup point in the first storage space until the state data of the blockchain block and the smart contract are updated to the block corresponding to the block identifier. After that, the correct on-chain transaction can be executed, thereby realizing the data rollback operation.

[0106] It should be noted that when the blockchain is a consortium blockchain, because the consortium blockchain uses a deterministic consensus protocol, it can ensure that the blockchain stored by each node is consistent. Therefore, data rollback operations are usually not required for consortium blockchains.

[0107] In this embodiment, when the backup point is reached, the data in the target description file can be persistently stored, which can ensure the persistence of the data in the target description file. At the same time, the persistent storage of the data in the target description file can also realize the data rollback operation. Since the data rollback operation starts from the target backup point, it can ensure that fewer transactions are executed, focusing on changes to the state data of the smart contract. Therefore, the data rollback operation can be completed efficiently and quickly, improving the efficiency of the data rollback operation.

[0108] Please see Figure 6 , Figure 6 This is a flowchart illustrating a data processing method based on smart contracts provided in an embodiment of this application. Figure 4 This method comprises multiple modules: a smart contract execution engine, a structured representation language-based read / write driver (e.g., a JSON-based read / write driver), a memory object, and a state root accumulator. The smart contract execution engine is the virtual machine or container for executing smart contracts. When the smart contract execution engine initiates a data operation instruction regarding the state data of a target smart contract, the structured representation language-based read / write driver can convert the key targeted by the data operation instruction in the target smart contract into a key object to be operated on. Then, any one of the data reading, data insertion, data update, and data deletion modules in the structured representation language-based read / write driver can use the key object to be operated on to perform corresponding data operations on the target description file corresponding to the target smart contract in the memory object. These data operations include any one of data update, data insertion, and data deletion operations. Simultaneously, the state root accumulator iteratively accumulates the state root of the target smart contract based on changes to the data in the target description file.

[0109] When persistent storage of state data for smart contracts is required, such as Figure 7As shown in A1-A3, the blockchain main program can trigger a persistence process when the block height of the blockchain reaches the backup point. This process serializes the description files corresponding to each smart contract in the memory object and stores the resulting sequence stream data in the second storage space, thus completing the persistent storage of the smart contract's state data. Furthermore, if the blockchain main program discovers inconsistencies between its stored blockchain and those of other nodes during blockchain maintenance, it can perform a data rollback operation. For example... Figure 7 As shown in B1-B3, the blockchain main program can send a data rollback request to the storage engine corresponding to the second storage space. The storage engine can determine the target backup point based on the block identifier carried in the data rollback request, thereby reading the sequence stream data corresponding to the target backup point, deserializing the sequence stream data corresponding to the target backup point to obtain the description file corresponding to the target backup point, and reading the description file corresponding to the target backup point into a memory object. Then, the blockchain main program replays the transaction, including: determining the transaction to be replayed, calling the smart contract to execute the transaction to be replayed, and performing data operations on the description file corresponding to the target backup point in the memory object during the execution of the transaction to be replayed, thereby updating the state data of the block in the blockchain and the smart contract to the block corresponding to the block identifier, and then continuing to execute the correct on-chain transaction, thereby realizing the data rollback operation.

[0110] This embodiment enables the target description file to be directly read and written by external applications or by humans without the need for additional smart contract processing, thereby improving the efficiency of data processing for smart contract state data. In addition, it enables persistent storage of smart contract state data, and the persistent storage of smart contract state data can efficiently realize data rollback operations.

[0111] The methods of the embodiments of this application have been described in detail above. To facilitate better implementation of the methods of the embodiments of this application, the apparatus of the embodiments of this application is provided below. Please refer to... Figure 8 , Figure 8 This is a schematic diagram of a data processing device based on smart contracts provided in an embodiment of this application. A target description file corresponding to a target smart contract is stored in a designated storage space. The target description file is constructed based on the state data of the target smart contract. The target description file includes one or more key-value combinations, each key-value combination including a key object and a value object. The key object and the value object are determined based on the state data. The data processing device 80 may include:

[0112] Processing unit 801 is configured to determine the key object to be operated indicated by the data operation instruction in response to a data operation instruction regarding the state data of the target smart contract;

[0113] The processing unit 801 is further configured to, if the data operation instruction is a first operation instruction, execute the data operation indicated by the data operation instruction on the value object corresponding to the key object to be operated on in the target description file; wherein, the first operation instruction includes one or more of a data read instruction, a data update instruction, and a data delete instruction;

[0114] The processing unit 801 is further configured to, if the data operation instruction is a second operation instruction, determine the reference value corresponding to the key object to be operated indicated by the data operation instruction, and associate and record the key object to be operated and the reference value in the target description file; wherein, the second operation instruction includes a data insertion instruction.

[0115] In one embodiment, the processing unit 801 is specifically used to: determine the operation object corresponding to the data operation instruction; when there are multiple operation objects, determine the hierarchical relationship between the multiple operation objects; perform cascading processing on the multiple operation objects according to the hierarchical relationship, and determine the key object to be operated indicated by the data operation instruction according to the cascading processing result.

[0116] In one embodiment, the processing unit 801 is specifically used to: determine state root iteration data based on the key object to be operated on and the type of the data operation instruction;

[0117] The data processing device 80 further includes an acquisition unit 802, which is used to: acquire a reference state root of the target smart contract, wherein the reference state root is an initial state root or a state root generated after the last data operation on the data in the target description file;

[0118] The processing unit 801 is specifically used to: determine the target state root of the target smart contract based on the state root iteration data and the reference state root.

[0119] In one embodiment, the acquisition unit 802 is specifically used to: when the data operation instruction is the data insertion instruction or the data update instruction, acquire the target value corresponding to the key object to be operated indicated by the data operation instruction;

[0120] The processing unit 801 is specifically used to: determine the state root iteration data based on the target value corresponding to the key object to be operated, the key object to be operated, and the type of the data operation instruction.

[0121] In one embodiment, the target description file is stored in a first storage space, and the acquisition unit 802 is specifically used to: if the block height of the blockchain determines that a backup point has been reached, then acquire the target description file from the first storage space;

[0122] The processing unit 801 is specifically used to: serialize the data in the target description file to obtain the sequence stream data corresponding to the target description file; and save the sequence stream data corresponding to the target description file to a second storage space, wherein the second storage space is different from the first storage space.

[0123] In one embodiment, the processing unit 801 is specifically configured to: in response to a data rollback request, determine a target backup point based on a block identifier carried in the data rollback request; wherein the target backup point is the nearest backup point before the block height corresponding to the block identifier;

[0124] The acquisition unit 802 is specifically used to: acquire the sequence stream data corresponding to the target backup point from the second storage space;

[0125] The processing unit 801 is specifically used to perform a data rollback operation based on the sequence stream data corresponding to the target backup point.

[0126] In one embodiment, the block identifier includes the identifier corresponding to a reference block in the blockchain whose block header information is inconsistent. The block header information is determined based on the state root of a reference smart contract, which is the smart contract invoked when the reference block is packaged and generated.

[0127] In one embodiment, the processing unit 801 is specifically used to: deserialize the sequence stream data corresponding to the target backup point to obtain a description file corresponding to the target backup point; write the description file corresponding to the target backup point into the first storage space; determine the transaction to be replayed, and perform a data rollback operation based on the transaction to be replayed and the description file corresponding to the target backup point in the first storage space.

[0128] It is understood that the functions of each functional unit of the data processing device described in the embodiments of this application can be specifically implemented according to the methods in the above method embodiments, and the specific implementation process can be referred to the relevant descriptions in the above method embodiments, which will not be repeated here.

[0129] In this embodiment, in response to a data operation instruction regarding the state data of a target smart contract, the key object to be operated indicated by the data operation instruction is determined. When the data operation instruction is a first operation instruction, the data operation indicated by the data operation instruction is executed on the value object corresponding to the key object to be operated in the target description file. When the data operation instruction is a second operation instruction, the reference value corresponding to the key object to be operated indicated by the data operation instruction is determined. The key object to be operated and the reference value are associated and recorded in the target description file, which can improve the efficiency of data operation on the state data of the target smart contract.

[0130] like Figure 9 As shown, Figure 9 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. The internal structure of the computer device 90 is as follows: Figure 9 As shown, it includes: one or more processors 901, a memory 902, and a communication interface 903. The processors 901, memory 902, and communication interface 903 can be connected via a bus 904 or other means; this embodiment of the application takes connection via bus 904 as an example.

[0131] The processor 901 (or CPU, Central Processing Unit) is the computing and control core of the computer device 90. It can parse various instructions within the computer device 90 and process various data. For example, the CPU can parse power-on / off commands sent by the user to the computer device 90 and control the computer device 90 to perform power-on / off operations; it can also transmit various interactive data between internal structures of the computer device 90, and so on. The communication interface 903 may optionally include standard wired interfaces or wireless interfaces (such as Wi-Fi, mobile communication interfaces, etc.), and is controlled by the processor 901 for sending and receiving data. The memory 902 is a storage device in the computer device 90 used to store computer programs and data. It is understood that the memory 902 here can include the computer device 90's built-in memory, or it can include extended memory supported by the computer device 90. The memory 902 provides storage space for the computer device 90's operating system, which may include, but is not limited to, Windows, Linux, Android, iOS, etc., and this application does not limit this.

[0132] A target description file corresponding to a target smart contract is stored in a designated storage space. The target description file is constructed based on the state data of the target smart contract. The target description file includes one or more key-value combinations, each key-value combination including a key object and a value object. The key object and the value object are determined based on the state data. The processor 901 executes the following operations by running the computer program stored in the memory 902:

[0133] In response to a data manipulation instruction regarding the state data of the target smart contract, determine the key object to be manipulated as indicated by the data manipulation instruction;

[0134] If the data operation instruction is a first operation instruction, then for the value object corresponding to the key object to be operated on in the target description file, the data operation indicated by the data operation instruction is executed; wherein, the first operation instruction includes one or more of the following: data read instruction, data update instruction, and data delete instruction;

[0135] If the data operation instruction is a second operation instruction, then the reference value corresponding to the key object to be operated indicated by the data operation instruction is determined, and the key object to be operated and the reference value are associated and recorded in the target description file; wherein, the second operation instruction includes a data insertion instruction.

[0136] In one embodiment, the processor 901 is specifically configured to: determine the operation object corresponding to the data operation instruction; when there are multiple operation objects, determine the hierarchical relationship between the multiple operation objects; perform cascading processing on the multiple operation objects according to the hierarchical relationship, and determine the key object to be operated indicated by the data operation instruction according to the cascading processing result.

[0137] In one embodiment, the processor 901 is specifically configured to: determine state root iteration data based on the key object to be operated on and the type of the data operation instruction; obtain a reference state root of the target smart contract, wherein the reference state root is an initial state root or a state root generated after the last data operation on the data in the target description file; and determine the target state root of the target smart contract based on the state root iteration data and the reference state root.

[0138] In one embodiment, the processor 901 is specifically configured to: when the data operation instruction is the data insertion instruction or the data update instruction, obtain the target value corresponding to the key object to be operated indicated by the data operation instruction; and determine the state root iteration data according to the target value corresponding to the key object to be operated, the key object to be operated, and the type of the data operation instruction.

[0139] In one embodiment, the target description file is stored in a first storage space, and the processor 901 is specifically configured to: if the block height of the blockchain determines that a backup point has been reached, retrieve the target description file from the first storage space; serialize the data in the target description file to obtain the sequence stream data corresponding to the target description file; and save the sequence stream data corresponding to the target description file to a second storage space, the second storage space being different from the first storage space.

[0140] In one embodiment, the processor 901 is specifically configured to: in response to a data rollback request, determine a target backup point based on a block identifier carried in the data rollback request; wherein the target backup point is the nearest backup point before the block height corresponding to the block identifier; obtain the sequence stream data corresponding to the target backup point from the second storage space; and perform a data rollback operation based on the sequence stream data corresponding to the target backup point.

[0141] In one embodiment, the block identifier includes the identifier corresponding to a reference block in the blockchain whose block header information is inconsistent. The block header information is determined based on the state root of a reference smart contract, which is the smart contract invoked when the reference block is packaged and generated.

[0142] In one embodiment, the processor 901 is specifically configured to: deserialize the sequence stream data corresponding to the target backup point to obtain a description file corresponding to the target backup point; write the description file corresponding to the target backup point into the first storage space; determine the transaction to be replayed, and perform a data rollback operation based on the transaction to be replayed and the description file corresponding to the target backup point in the first storage space.

[0143] In specific implementations, the processor 901, memory 902, and communication interface 903 described in the embodiments of this application can execute the implementation method described in the data processing method based on smart contracts provided in the embodiments of this application, or they can execute the implementation method described in the data processing device based on smart contracts provided in the embodiments of this application, which will not be repeated here.

[0144] In this embodiment, in response to a data operation instruction regarding the state data of a target smart contract, the key object to be operated indicated by the data operation instruction is determined. When the data operation instruction is a first operation instruction, the data operation indicated by the data operation instruction is executed on the value object corresponding to the key object to be operated in the target description file. When the data operation instruction is a second operation instruction, the reference value corresponding to the key object to be operated indicated by the data operation instruction is determined. The key object to be operated and the reference value are associated and recorded in the target description file, which can improve the efficiency of data operation on the state data of the target smart contract.

[0145] This application also provides a computer-readable storage medium storing a computer program that, when run on a computer device, causes the computer device to execute any of the above-described possible implementations of the smart contract-based data processing method. Specific implementation details are provided above and will not be repeated here.

[0146] This application also provides a computer program product, which includes a computer program or computer instructions. When executed by a processor, the computer program or computer instructions implement the steps of the smart contract-based data processing method provided in this application. The specific implementation method can be found in the foregoing description and will not be repeated here.

[0147] This application also provides a computer program comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the smart contract-based data processing method provided in this application. The specific implementation can be found in the preceding description and will not be repeated here.

[0148] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0149] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc.

[0150] The above-disclosed embodiments are only some of the embodiments of this application, and should not be construed as limiting the scope of this application. Therefore, any equivalent changes made in accordance with the claims of this application shall still fall within the scope of this application.

Claims

1. A data processing method based on smart contracts, characterized in that, A target description file corresponding to the target smart contract is stored in a designated storage space, wherein the designated storage space is memory. The target description file is constructed by encapsulating the state data of the target smart contract using a structured representation language. The target description file includes one or more key-value pairs, each key-value pair including a key object and a value object. The key object is the attribute name of the state data, and the value object is the attribute value of the state data. The method includes: In response to a data manipulation instruction regarding the state data of the target smart contract, determine the key object to be manipulated as indicated by the data manipulation instruction; If the data operation instruction is a first operation instruction, then for the value object corresponding to the key object to be operated on in the target description file, the data operation indicated by the data operation instruction is executed; wherein, the first operation instruction includes one or more of the following: data read instruction, data update instruction, and data delete instruction; If the data operation instruction is a second operation instruction, then the reference value corresponding to the key object to be operated indicated by the data operation instruction is determined, and the key object to be operated and the reference value are associated and recorded in the target description file; wherein, the second operation instruction includes a data insertion instruction; The state root iteration data is determined based on the key object to be operated on and the type of the data operation instruction; Obtain the reference state root of the target smart contract, wherein the reference state root is either the initial state root or the state root generated after the last data operation on the data in the target description file; The target state root of the target smart contract is determined based on the state root iteration data and the reference state root.

2. The method according to claim 1, characterized in that, The step of determining the key object to be operated on, as indicated by the data operation instruction, includes: Determine the operation object corresponding to the data operation instruction; When there are multiple operation objects, the hierarchical relationship between the multiple operation objects is determined; The multiple operation objects are cascaded according to the hierarchical relationship, and the key object to be operated indicated by the data operation instruction is determined according to the cascaded processing result.

3. The method according to claim 1 or 2, characterized in that, The step of determining the state root iteration data based on the key object to be operated on and the type of the data operation instruction includes: When the data operation instruction is the data insertion instruction or the data update instruction, obtain the target value corresponding to the key object to be operated indicated by the data operation instruction; The state root iteration data is determined based on the target value corresponding to the key object to be operated on, the key object to be operated on, and the type of the data operation instruction.

4. The method according to claim 1, characterized in that, The target description file is stored in the first storage space, and the method further includes: If the blockchain block height determines that the backup point has been reached, then the target description file is retrieved from the first storage space; The data in the target description file is serialized to obtain the sequence stream data corresponding to the target description file; The sequence stream data corresponding to the target description file is saved to a second storage space, which is different from the first storage space.

5. The method according to claim 4, characterized in that, The method further includes: In response to a data rollback request, a target backup point is determined based on the block identifier carried in the data rollback request; wherein, the target backup point is the nearest backup point before the block height corresponding to the block identifier; Obtain the sequence stream data corresponding to the target backup point from the second storage space; Perform a data rollback operation based on the sequence stream data corresponding to the target backup point.

6. The method according to claim 5, characterized in that, The block identifier includes the identifier corresponding to the reference block whose block header information is inconsistent in the blockchain. The block header information is determined based on the state root of the reference smart contract, which is the smart contract called when the reference block is packaged and generated.

7. The method according to claim 5 or 6, characterized in that, The data rollback operation based on the sequence stream data corresponding to the target backup point includes: The sequence stream data corresponding to the target backup point is deserialized to obtain the description file corresponding to the target backup point; Write the description file corresponding to the target backup point into the first storage space; The transaction to be replayed is identified, and a data rollback operation is performed based on the transaction to be replayed and the description file corresponding to the target backup point in the first storage space.

8. A data processing device based on smart contracts, characterized in that, A target description file corresponding to a target smart contract is stored in a designated storage space, wherein the designated storage space is memory. The target description file is constructed by encapsulating the state data of the target smart contract using a structured representation language. The target description file includes one or more key-value pairs, each key-value pair including a key object and a value object. The key object is the attribute name of the state data, and the value object is the attribute value of the state data. The device includes: The processing unit is configured to, in response to a data operation instruction regarding the state data of the target smart contract, determine the key object to be operated as indicated by the data operation instruction; The processing unit is further configured to, if the data operation instruction is a first operation instruction, execute the data operation indicated by the data operation instruction on the value object corresponding to the key object to be operated on in the target description file; wherein, the first operation instruction includes one or more of a data read instruction, a data update instruction, and a data delete instruction; The processing unit is further configured to, if the data operation instruction is a second operation instruction, determine the reference value corresponding to the key object to be operated indicated by the data operation instruction, and associate and record the key object to be operated and the reference value in the target description file; wherein, the second operation instruction includes a data insertion instruction; The processing unit is further configured to: determine state root iteration data based on the key object to be operated on and the type of the data operation instruction; obtain a reference state root of the target smart contract, wherein the reference state root is an initial state root or a state root generated after the last data operation on the data in the target description file; and determine the target state root of the target smart contract based on the state root iteration data and the reference state root.

9. A computer device, characterized in that, The computer device includes a memory, a communication interface, and a processor, wherein the memory, the communication interface, and the processor are interconnected; the memory stores a computer program, and the processor calls the computer program stored in the memory to implement the data processing method based on smart contracts as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the data processing method based on smart contracts as described in any one of claims 1 to 7.

11. A computer program product, characterized in that, The computer program product includes a computer program or computer instructions, which, when executed by a processor, implement the data processing method based on smart contracts as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Block chain state data storage method and device and storage medium

    CN109559234A

  • Data storage method and device in block chain, electronic equipment and storage medium

    CN112269839A

  • Data processing method and device, equipment and storage medium

    CN112765269A