A blockchain-based data processing method, device, and readable storage medium

By detecting and archiving state subtrees that meet the conditions, the problem of insufficient blockchain storage resources is solved, and more efficient storage management and verification are achieved.

CN117633099BActive Publication Date: 2026-05-19TENPAY PAID TECH
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
TENPAY PAID TECH
Filing Date
2022-08-15
Publication Date
2026-05-19

AI Technical Summary

Technical Problem

As data continues to increase, blockchain storage resources become insufficient, leading to storage space shortages and slower response times.

Method used

By detecting state subtrees that meet the state archiving conditions, archived transactions are generated, archived to the service device, and the corresponding nodes are deleted from the blockchain, reducing the storage of old data.

Benefits of technology

It reduces the storage burden on the blockchain, improves the utilization of storage space, and simplifies the data verification process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117633099B_ABST
    Figure CN117633099B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a data processing method and device based on a blockchain and a readable storage medium. The method comprises: if a consensus node detects that a first state sub-tree satisfying a state archiving condition exists in a target state tree, generating an archiving transaction according to a first leaf node of the first state sub-tree and a first sub-root node of the first state sub-tree; the first leaf node is used to represent a current state of first object information; if the archiving transaction is successfully chained, calling a state archiving function in a smart contract to archive the first state sub-tree in a service device through the state archiving function; a service provided by the service device is associated with the first object information; in the target state tree, nodes other than the first sub-root node in the first state sub-tree are deleted; the first sub-root node in the target state tree is used to indicate that the first state sub-tree has been archived. By using the present application, the storage resources of the blockchain can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of Internet technology, and in particular to a data processing method, device and readable storage medium based on blockchain. Background Technology

[0002] With the rapid development of network technology and enterprises' emphasis on data security, blockchain has received great attention and application.

[0003] For a credible blockchain, its storage space is limited. As the blockchain continues to operate, the amount of data it stores will continue to increase. At this point, the blockchain will face the dilemma of insufficient storage resources. Summary of the Invention

[0004] This application provides a blockchain-based data processing method, device, and readable storage medium, which can reduce the storage resources required for blockchain.

[0005] One embodiment of this application provides a blockchain-based data processing method, including:

[0006] If a consensus node detects that there is a first state subtree in the target state tree that meets the state archiving conditions, it generates an archived transaction based on the first leaf node and the first root node of the first state subtree; the first leaf node is used to represent the current state of the first object information.

[0007] If the archived transaction is successfully uploaded to the blockchain, the state archiving function in the smart contract is called. Through the state archiving function, the first state subtree is archived in the service device; the business services provided by the service device are associated with the first object information.

[0008] In the target state tree, all nodes in the first state subtree except the first root node are deleted; the first root node in the target state tree is used to indicate that the first state subtree has been archived.

[0009] One embodiment of this application provides a blockchain-based data processing device, which operates on a consensus node and includes:

[0010] The first generation module is used to generate archived transactions based on the first leaf node and the first root node of the first state subtree if the consensus node detects that there is a first state subtree in the target state tree that meets the state archiving conditions; the first leaf node is used to represent the current state of the first object information.

[0011] The state archiving module is used to call the state archiving function in the smart contract if the archived transaction is successfully uploaded to the chain. Through the state archiving function, the first state subtree is archived in the service device; the business services provided by the service device are associated with the first object information.

[0012] The first deletion module is used to delete nodes in the first state subtree except for the first root node in the target state tree; the first root node in the target state tree is used to indicate that the first state subtree has been archived.

[0013] The blockchain-based data processing device also includes:

[0014] The first determining module is used to determine the total number of the first leaf nodes. If the total number of the first leaf nodes is equal to or greater than the archived number threshold, the generation timestamp of the first child root node is obtained.

[0015] The second determining module is used to determine the maintenance duration of the first child root node based on the generated timestamp. If the maintenance duration is equal to or greater than the maintenance duration threshold, then the first state subtree is determined to meet the state archiving condition.

[0016] The first generation module includes:

[0017] The first acquisition unit is used to acquire the first index number for the first leaf node in the target state tree;

[0018] The first generation unit is used to generate archived transactions based on the first index number and the first child root node of the first state subtree, and to process the archived transactions on the blockchain.

[0019] The blockchain-based data processing device also includes:

[0020] The first synchronization module is used to synchronize archived transactions to business nodes in the blockchain; the archived transactions are used to instruct business nodes to perform legality verification on the information of the object to be verified associated with the first index number according to the first child root node.

[0021] The blockchain-based data processing device also includes:

[0022] The second generation module is used to generate a subtree merging transaction based on the second root node, the first root node, and the parent node of the first subtree if the parent node of the second state subtree and the parent node of the first state subtree are the same node in the target state tree. The second state subtree is a state subtree in the target state tree that meets the state archiving conditions, and the archiving timestamp of the second state subtree is earlier than the archiving timestamp of the first state subtree.

[0023] The second deletion module is used to process the subtree merging transaction on the blockchain. If the subtree merging transaction is successfully uploaded to the blockchain, the first and second child root nodes will be deleted in the target state tree. The parent node of the first state subtree in the target state tree is used to indicate that the first and second state subtrees have been archived.

[0024] Among them, the state archiving function has the function of calling back the first storage address of the first state subtree when the service device successfully stores the first state subtree, and has the function of associating the first storage address and the first child root node for storage.

[0025] The blockchain-based data processing device also includes:

[0026] The first acquisition module is used to acquire the status query request sent by the blockchain node carrying the second object information, and determine the second index number that has a mapping relationship with the second object information in the target state tree according to the status query request.

[0027] The archiving prompt module is used to return archiving prompt information carrying the first storage address and the first child root node to the blockchain node if the second index number belongs to the first index number for the first leaf node in the target state tree. The archiving prompt information is used to instruct the blockchain node to query the first state subtree in the service device according to the first storage address, and to obtain the leaf node corresponding to the second object information in the first state subtree. The first child root node is used to verify the legality of the leaf node corresponding to the second object information.

[0028] The status archiving module includes:

[0029] The second acquisition unit is used to acquire the second storage address of the second state subtree in the service device if the parent node to which the second state subtree belongs and the parent node to which the first state subtree belongs are the same node in the target state tree; the second state subtree is a state subtree in the target state tree that meets the state archiving conditions, and the archiving timestamp corresponding to the second state subtree is earlier than the archiving timestamp corresponding to the first state subtree.

[0030] The address sending unit is used to send the parent node of the first state subtree, the first state subtree, and the second storage address to the service device through the state archiving function, so that the service device writes the first state subtree and the parent node of the first state subtree according to the second storage address, and merges the first state subtree and the second state subtree to obtain a merged state subtree; the parent node of the first state subtree is the root of the merged state subtree.

[0031] The first deletion module is also used to synchronously delete the first root node of the first state subtree and the second root node of the second state subtree; the parent node of the first state subtree in the target state tree is used to indicate that both the first state subtree and the second state subtree have been archived.

[0032] The state archiving module is specifically used to obtain business data associated with the first state subtree in the blockchain, and archive both the business data and the first state subtree in the service device through the state archiving function.

[0033] The first deletion module is also used to delete the business data in the blockchain if it receives successful archiving information for the business data and the first state subtree returned by the service device.

[0034] The first object information includes the first business information;

[0035] The blockchain-based data processing device also includes:

[0036] The second acquisition module is used to acquire the first service information provided by the service device;

[0037] The state initialization module is used in smart contracts to construct an initial state tree including at least two initial leaf nodes; the at least two initial leaf nodes include a first initial leaf node for the first business information; the first initial leaf node is used to indicate that there is no business transaction containing the first business information on the blockchain; the first business information includes second business information;

[0038] The third acquisition module is used to acquire the first business transaction including the second business information, and update the first initial leaf node in the initial state tree to the first leaf node according to the first business transaction.

[0039] The third determination module is used to determine the initial state tree with the first leaf node as the target state tree.

[0040] The second acquisition module is specifically used to acquire at least two pieces of service information provided by the service device; the at least two pieces of service information include the first piece of service information.

[0041] The state initialization module includes:

[0042] The first determining unit is used to determine the total number of information items for at least two business information items, and to determine the total number of leaves based on the total number of information items.

[0043] State initialization unit, used in smart contracts to construct an initial state tree including at least two initial leaf nodes; the total number of at least two initial leaf nodes is equal to the total number of leaves;

[0044] The third acquisition unit is used to determine, in the initial state tree, index numbers used to characterize at least two initial leaf nodes respectively; the at least two index numbers include a first index number used to characterize the first initial leaf node;

[0045] The second determining unit is used to construct a mapping relationship for at least two index numbers and at least two business information; wherein, there is a mapping relationship between the first index number and the first business information.

[0046] The third acquisition module includes:

[0047] The fourth acquisition unit is used to process the first business transaction on the blockchain. If the first business transaction is successfully uploaded to the blockchain, the current status of the second business information is obtained based on the first business transaction.

[0048] The second generation unit is used to generate a current state value that represents the current state of the second business information based on the current state of the second business information.

[0049] The node update unit is used to update the first initial leaf node according to the current state value to obtain the first leaf node.

[0050] The second generation unit includes:

[0051] The first update subunit is used to obtain the update state for updating the current state of the second business information if a second business transaction including the second business information is obtained within the state update period for the current state of the second business information, and the second business transaction is successfully uploaded to the chain, based on the second business transaction.

[0052] The current generation subunit is used to generate a current state value that represents the current state of the second service information if the current state of the second service information is maintained within the state update cycle.

[0053] The node update unit includes:

[0054] The second update subunit is used to update the initial state value in the first initial leaf node to the current state value; the first initial leaf node uses the initial state value to indicate that there is no business transaction containing the first business information in the blockchain;

[0055] The node determination sub-unit is used to determine the first initial leaf node that has been updated with the current state value as the first leaf node.

[0056] The blockchain-based data processing device also includes:

[0057] The fourth acquisition module is used to acquire the target root of the target state tree if the system time reaches the root update cycle; the target root is different from the initial root of the initial state tree.

[0058] The third generation module is used to generate tree root publishing transactions based on the system time and the target tree root, and to process the tree root publishing transactions on the blockchain.

[0059] The second synchronization module is used to generate synchronization data for business nodes based on the target state tree if the transaction published by the root of the tree is successfully uploaded to the chain, and then synchronize the synchronization data to the business nodes; the business nodes belong to the blockchain.

[0060] The second synchronization module includes:

[0061] The fifth acquisition unit is used to acquire, in the target state tree, the synchronization leaf node with synchronization permission of the business node, and the state verification path corresponding to the synchronization leaf node.

[0062] The third generation unit is used to generate synchronization data based on the synchronized leaf nodes, the state verification path, and the root transaction. The synchronization data is used to instruct the business nodes to perform legality verification on the synchronized leaf nodes based on the target root and the state verification path in the root transaction.

[0063] This application provides a computer device, including: a processor, a memory, and a network interface;

[0064] The processor is connected to the memory and the network interface, wherein the network interface is used to provide data communication functions, the memory is used to store computer programs, and the processor is used to call the computer programs so that the computer device executes the methods in the embodiments of this application.

[0065] One aspect of this application provides a computer-readable storage medium storing a computer program adapted for loading by a processor and executing the methods described in this application.

[0066] One aspect of this application provides a computer program product, which includes a computer program stored in a computer-readable storage medium; a processor of a computer device reads the computer program from the computer-readable storage medium and executes the computer program, causing the computer device to perform the method described in this application.

[0067] In this embodiment, if a first state subtree satisfying the state archiving conditions is detected in the target state tree, an archiving transaction can be generated based on the first leaf node and the first root node of the first state subtree. The first leaf node represents the current state of the first object information. If the archiving transaction is successfully uploaded to the blockchain, the state archiving function in the smart contract is called. Through this function, the first state subtree can be archived on the service device, where the business services provided by the service device are associated with the first object information. Simultaneously, in the target state tree, all nodes in the first state subtree except the first root node are deleted. At this point, the first root node in the target state tree indicates that the first state subtree has been archived. As can be seen from the above, this embodiment can archive first state subtrees that satisfy the state archiving conditions. This archiving process reduces the storage of old data (including the first state subtree) in the blockchain, thus alleviating storage resource requirements. Attached Figure Description

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

[0069] Figure 1 This is a schematic diagram of a system architecture provided in an embodiment of this application;

[0070] Figure 2a This application provides an example of a blockchain-based data processing scenario. Figure 1 ;

[0071] Figure 2b This is a schematic diagram of a data processing scenario based on blockchain provided in an embodiment of this application;

[0072] Figure 3 This is a flowchart illustrating a blockchain-based data processing method provided in an embodiment of this application. Figure 1 ;

[0073] Figure 4 This application provides an example of a blockchain-based data processing scenario. Figure 3 ;

[0074] Figure 5 This application provides an example of a blockchain-based data processing scenario. Figure 4 ;

[0075] Figure 6This is a schematic diagram of a data processing method based on blockchain provided in an embodiment of this application;

[0076] Figure 7 This application provides an example of a blockchain-based data processing scenario. Figure 5 ;

[0077] Figure 8 This application provides an example of a blockchain-based data processing scenario. Figure 6 ;

[0078] Figure 9 This is a flowchart illustrating a blockchain-based data processing method provided in an embodiment of this application. Figure 3 ;

[0079] Figure 10 This application provides an example of a blockchain-based data processing scenario. Figure 7 ;

[0080] Figure 11 This is a schematic diagram of the structure of a blockchain-based data processing device provided in an embodiment of this application;

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

[0082] The technical solutions of 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 of 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.

[0083] To facilitate understanding, the following brief explanations are provided for some of the terms:

[0084] 1. Blockchain: In a narrow sense, blockchain is a chain-like data structure with blocks as the basic unit. Blocks use digital digests to verify previously obtained transaction history, making it suitable for the tamper-proof and scalable requirements of distributed ledger scenarios. In a broader sense, blockchain also refers to the distributed ledger technology implemented using the blockchain structure, including distributed consensus, privacy and security protection, peer-to-peer communication technology, network protocols, and smart contracts. The goal of blockchain is to implement a distributed data record ledger that only allows additions, not deletions. The underlying basic structure of the ledger is a linear linked list. The linked list consists of a series of "blocks," with each subsequent block recording the hash value of the previous block. The validity of each block (and the transactions within it) can be quickly verified by calculating the hash value. If a node in the network proposes to add a new block, the block must be confirmed through a consensus mechanism.

[0085] For a credible blockchain, its computing resources and storage space are limited. Therefore, as the number of blocks increases, the available storage space corresponding to the credible blockchain may be insufficient, and the response may be slower than the request. At this time, it is necessary to alleviate the storage space of the blockchain.

[0086] 2. Hash Value: Also known as an information feature value or characteristic value, a hash value is generated by converting input data of arbitrary length into cryptography using a hash algorithm and producing a fixed output. The original input data cannot be retrieved by decrypting the hash value; it is a one-way encryption function. The hash value is a core and crucial aspect of blockchain technology, preserving the authenticity of recorded and viewed data, as well as the integrity of the blockchain as a whole.

[0087] 3. Blockchain Nodes: Blockchain networks divide nodes into consensus nodes (also known as core nodes or full nodes) and business nodes (also known as light nodes). Consensus nodes are responsible for the consensus process across the entire blockchain network; business nodes are responsible for synchronizing the ledger information from the consensus nodes, i.e., synchronizing the latest block data. Both consensus nodes and business nodes include network communication components in their internal structure, because a blockchain network is essentially a peer-to-peer (P2P) network, requiring communication with other nodes in the blockchain network through P2P components. Resources and services in the blockchain network are distributed across various nodes; information transmission and service implementation occur directly between nodes, without the need for intermediaries or centralized servers (third parties).

[0088] 4. Merkle Tree and Merkle Root: A Merkle tree is a typical binary tree structure, consisting of a root node (Merkle root), a set of intermediate nodes, and a set of leaf nodes. The bottom-level leaf nodes store data or its hash value, while other nodes store the hash values ​​of the contents of their two child nodes. In this embodiment, the target state tree is a Merkle tree generated for the state of object information, where the object information can be address information (e.g., digital wallet account) and business information (e.g., invoice number).

[0089] 5. Smart Contract: A smart contract is a computer protocol designed to disseminate, verify, or execute contracts in an informational manner. In a blockchain system, a smart contract (or simply contract) is code that all nodes on the blockchain can understand and execute, capable of performing arbitrary logic and producing results. In practical applications, smart contracts are managed and tested through transactions on the blockchain. Each transaction is equivalent to a Remote Procedure Call (RPC) request to the blockchain system. If a smart contract is like an executable program, the blockchain is like the operating system that provides the runtime environment. A blockchain can contain multiple contracts (such as the state archiving function in this application), distinguished by contract identity (ID), identifier, or name.

[0090] Please see Figure 1 , Figure 1 This is a schematic diagram of a system architecture provided in an embodiment of this application. For example... Figure 1 As shown, the system architecture can be a blockchain network 10, which may include a witness network 10a and a consensus network 10b. Nodes in the witness network 10a can be called business nodes, possessing some data. Business nodes primarily perform business execution and do not participate in accounting consensus. They obtain block header data and some authorized visible data (such as the synchronization data described above) from the consensus network 10b through identity authentication. The consensus network 10b can also be called the core network, and nodes in the consensus network 10b can be called consensus nodes, possessing all the data. The witness network 10a and the consensus network 10b operate in different network environments. Typically, the witness network 10a is in a public network while the consensus network 10b is in a private network, and the two interact through a routing boundary.

[0091] Please see again. Figure 1Witness network 10a may include business node 101a, business node 102a, business node 103a, ..., business node 104a. It is understood that witness network 10a may include one or more witness networks. In practical applications, due to different application scenarios, one or more types of witness networks can be set up; the number of witness networks is not limited here. Witness network 10a may include one or more business nodes; the number of business nodes is not limited here.

[0092] Please see again. Figure 1 Consensus network 10b may include consensus node 101b, consensus node 102b, consensus node 103b, ..., consensus node 104b. It is understood that the aforementioned consensus network 10b may include one or more consensus networks. In practical applications, due to different application scenarios, one or more types of consensus networks can be set up; the number of consensus networks will not be limited here. The aforementioned consensus network 10b may include one or more consensus nodes; the number of consensus nodes will not be limited here.

[0093] Each blockchain node (including the consensus node in consensus network 10b and the business node in witness network 10a) can receive transaction data sent by the client (such as the first business transaction and the second business transaction described below) during normal operation, generate a block based on the received transaction data, and then perform block on-chain processing. It is understood that in the specific embodiments of this application, data related to user information (such as the first business transaction) is involved. When the embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions.

[0094] To ensure data communication between blockchain nodes, data connections can exist between each blockchain node. For example, there is a data connection between business node 101a and business node 102a, a data connection between business node 101a and business node 103a, and a data connection between consensus node 101b and consensus node 104b.

[0095] Furthermore, there are data connections between witness network 10a and consensus network 10b. For example, there are data connections between business node 101a and consensus node 102b, business node 101a and consensus node 103b, and consensus node 101b and business node 104a.

[0096] It is understandable that blockchain nodes can transmit data or blocks through the aforementioned data connections. These data connections between blockchain nodes can be based on node identifiers. Each blockchain node in the blockchain network 10 has a corresponding node identifier, and each blockchain node can store the node identifiers of other blockchain nodes that are connected to it. This allows it to broadcast acquired data or generated blocks to other blockchain nodes based on their node identifiers. For example, business node 101a can maintain a node identifier list as shown in Table 1, which stores the node names and node identifiers of other blockchain nodes.

[0097] Table 1

[0098] Node Name Node identifier Consensus Node 101b AAAAA Consensus node 102b BBBBB … … Consensus node 104b CCCCC Business Node 102a DDDDD Business Node 103a EEEEE … …

[0099] The node identifier can be an Internet Protocol (IP) address used for interconnecting networks, or any other information that can be used to identify a blockchain node in a blockchain network.

[0100] Assuming the node identifier of business node 101a is FFFFFF, business node 101a can send transaction data to be uploaded to the chain to consensus node 104b through the node identifier CCCCC. Consensus node 104b can determine that the transaction data to be uploaded to the chain was sent by business node 101a through the node identifier FFFFFF. Similarly, consensus node 104b can send a block consensus request to consensus node 102b through the node identifier BBBBBBB. Consensus node 102b can determine that the block consensus request was sent by consensus node 104b through the node identifier CCCCCC. Data transmission between other blockchain nodes is also in the same way, so it will not be elaborated on one by one.

[0101] It is understood that the above data connection is not limited to the connection method. It can be connected directly or indirectly through wired communication, or directly or indirectly through wireless communication, or through other connection methods. This application does not impose any restrictions on this.

[0102] in, Figure 1 The business nodes 101a, 102a, 103a, ..., 104a, consensus nodes 101b, 102b, 103b, ..., 104b can include mobile phones, tablets, laptops, PDAs, smart speakers, mobile internet devices (MIDs), POS (Point of Sales) machines, wearable devices (such as smartwatches, smart bracelets, etc.).

[0103] It is understood that the blockchain-based data processing method provided in this application embodiment can be executed by computer devices, including but not limited to business nodes (which can be terminals or servers) or consensus nodes (which can be terminals or servers). The aforementioned servers can be independent physical servers, server clusters or distributed systems composed of multiple physical servers, or cloud servers 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, content delivery networks (CDNs), and big data and artificial intelligence platforms. The aforementioned terminal devices include but are not limited to mobile phones, computers, smart voice interaction devices, smart home appliances, vehicle terminals, and aircraft. The terminal devices and servers can be directly or indirectly connected via wired or wireless means, and this application embodiment does not impose any restrictions on this.

[0104] Further, please see Figure 2a , Figure 2a This application provides an example of a blockchain-based data processing scenario. Figure 1 This application's embodiments can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, and assisted driving. This application's embodiments are applicable to business scenarios such as on-chain processing, modification processing, destruction processing, and query processing of object information (e.g., addresses, tickets), and these will not be listed individually here. The implementation process of this data processing scenario can be performed in the blockchain's consensus nodes, in the blockchain's business nodes, or through interaction between the consensus nodes and business nodes; no limitations are imposed here. For ease of description and understanding, this application's embodiments will be described using the consensus node as an example, where the consensus node can be one of the aforementioned... Figure 1 Any consensus node in the consensus network 10b of the corresponding embodiment.

[0105] like Figure 2a As shown, consensus node 20a can generate target state tree 20d. For the specific process of consensus node 20a generating target state tree 20d, please refer to the following text. Figure 9The description of the object information is omitted here. The target state tree 20d is a Merkle tree used to store the current state of object information. This embodiment does not limit the object information; it can be a blockchain address. In this case, the target state tree 20d can represent the current state of all addresses. For example, "Address 1 = 20; Address 2 = 50" indicates that the current state (resource balance) of Address 1 is 20, and the current state of Address 2 is 50. Object information can also be business information, such as unique invoice numbers or transaction numbers. In this case, the target state tree 20d can represent the current state of all business information. For example, "Invoice No. 1 = 0; Invoice No. 2 = 1; Invoice No. 3 = 2" indicates that the current state of Invoice No. 1 is 0, where 0 indicates that Invoice No. 1 is not on the blockchain; the current state of Invoice No. 2 is 1, where 1 indicates that Invoice No. 2 is in the issuance state; and the current state of Invoice No. 3 is 2, where 2 indicates that Invoice No. 3 is in the red-inking state.

[0106] It is understandable that the above example is for the purpose of making it easier to understand object information and the current state of object information, and should not be used to limit the content of the target state tree. The content of the target state tree can be set according to the actual application scenario.

[0107] Please see again. Figure 2a The target state tree 20d can include leaf nodes, intermediate nodes, and a root node. Each leaf node has an index number, for example... Figure 2a In the example shown, index numbers 0000, 0001, ..., 0111 represent the index positions of leaf nodes in the target state tree 20d. This application embodiment does not limit the generation method of index numbers, as long as they are unique. A leaf node represents the current state of an object's information. The node one level above the leaf node is its hash value, and the node one level above that is the hash value corresponding to the hash values ​​of the two leaf nodes.

[0108] Consensus node 20a checks whether there is a state subtree in the target state tree 20d that satisfies the state archiving conditions. The specific process of consensus node 20a checking the state subtree is described below. Figure 3 The description of step S101 in the corresponding embodiment will not be elaborated here. If consensus node 20a detects that there is a first state subtree in the target state tree 20d that satisfies the state archiving conditions, then it generates an archived transaction based on the first leaf node and the first root node of the first state subtree. For example Figure 2a The example state subtree 201d (i.e., the first state subtree) satisfies the state archiving condition. Therefore, based on the first leaf node of state subtree 201d and the first root child node of state subtree 201d (e.g., ...), ... Figure 2aThe example root node 201c) and consensus node 20a can generate archived transactions. The first leaf node of the state subtree 201d may include the leaf node represented by index number 0000, the leaf node represented by index number 0001, the leaf node represented by index number 0010, and the leaf node represented by index number 0011.

[0109] Consensus node 20a processes the generated archived transactions onto the blockchain. The specific process may include: consensus node 20a broadcasting the archived transactions to the consensus network; the consensus network reaching a consensus on the archived transactions; and each consensus node storing the archived transactions upon successful consensus. If the archived transactions are successfully uploaded to the blockchain, the state archiving function 20e in the smart contract is called. Consensus node 20a uses state archiving function 20e to archive the first state subtree (…). Figure 2a (Taking state subtree 201d as an example) it is archived in service device 20f, where the business services provided by service device 20f are associated with first object information. First object information refers to the object information associated with the first leaf node. In this embodiment, a leaf node in the target state tree 20d is used to associate with one piece of object information; it can also be understood that a leaf node represents the current state of an object piece of information. For example, the leaf node represented by index 0100, the leaf node represented by index 0101, the leaf node represented by index 0110, and the leaf node represented by index 0111 are associated with different pieces of object information and are used to represent the current state of different pieces of object information.

[0110] In this embodiment of the application, the state archiving function 20e has the function of successfully storing the first state subtree (e.g., ...) on the service device 20f. Figure 2a When the example state subtree 201d is invoked, a function is called back for the first storage address of the first state subtree, and a function is called to store the first storage address and the first child root node (e.g. Figure 2a The example demonstrates the functionality of associative storage for the child root node 201c. Figure 2a As shown, upon successfully storing state subtree 201d, service device 20f can notify consensus node 20a of the first storage address used to store state subtree 201d via state archiving function 20e. Through state archiving function 20e, consensus node 20a can associate the first storage address with the root child node 201c for storage.

[0111] After the archived transaction is successfully uploaded to the blockchain, in the target state tree 20d, consensus node 20a will move the first state subtree (e.g., ...) Figure 2a In the state subtree 201d, except for the first child root node (e.g. Figure 2aNodes other than the root child node 201c (referred to as old nodes for ease of representation) are deleted to obtain the target state tree 202d. For example... Figure 2a As shown, the target state tree 202d does not include old nodes. At this time, the root child node 201c is used to indicate that the state subtree 201d has been archived.

[0112] It is understandable that the execution process of storing the first storage address can precede the execution process of deleting the old node, and the execution process of deleting the old node can also precede the execution process of storing the first storage address. Optionally, the execution process of storing the first storage address can be synchronized with the execution process of deleting the old node.

[0113] Furthermore, please combine Figure 2a as well as Figure 2b , Figure 2b This is a schematic diagram of a data processing scenario based on blockchain provided in this application embodiment. The blockchain node 20h can be any blockchain node in the blockchain, that is, it can be a consensus node or a business node. It can be the same blockchain node as the consensus node 20a, or it can be a different blockchain node. For ease of description, this application embodiment assumes that the blockchain node 20h and the consensus node are not the same blockchain node.

[0114] like Figure 2b As shown, consensus node 20a receives a state query request carrying the second object information sent by blockchain node 20h. Based on the state query request, consensus node 20a determines the second index number that has a mapping relationship with the second object information in the target state tree 202d.

[0115] If the second index number does not belong to the first index number for the first leaf node in the target state tree 202d, then the leaf node represented by the second index number is obtained. Here, the first index number refers to... Figure 2a The index number corresponding to the first leaf node of the example state subtree 201d, for example Figure 2a The examples use index numbers 0000 to 0011. Figure 2b As shown in the example, the second index number that maps to the second object information is index number 0111. Index number 0111 represents leaf node 203b, which has not yet been archived and is stored in the blockchain. Further, through the target state tree 202d, consensus node 20a obtains the verification data 20i of leaf node 203b, i.e., the Merkel path used to verify the legitimacy of leaf node 203b. Figure 2b As shown, the verification data 20i includes intermediate node 201b (the hash value of the leaf node represented by index number 0110), intermediate node 202b, and child root node 201c.

[0116] Furthermore, consensus node 20a sends leaf node 203b, which represents the current state of the second object information, and verification data 20i (i.e., intermediate nodes 201b, 202b, and root node 201c) to blockchain node 20h. After receiving leaf node 203b and verification data 20i, blockchain node 20h can verify the legitimacy of leaf node 203b using verification data 20i. The specific process may include: blockchain node 20h generating a hash value to be verified for leaf node 203b, then performing a hash calculation on the hash value to be verified for leaf node 203b and intermediate node 201b to obtain a first intermediate hash value to be verified; further, blockchain node 20h performing a hash calculation on the first intermediate hash value to be verified and intermediate node 202b to obtain a second intermediate hash value to be verified; further, performing a hash calculation on the second intermediate hash value to be verified and root node 201c to obtain a root hash value to be verified; and then blockchain node 20h comparing the root hash value to be verified with the target state tree broadcast in the blockchain. The root node of the target state tree 202d is compared. If the root hash value to be verified is the same as the root node of the target state tree 202d, then blockchain node 20h determines that leaf node 203b is valid state data. Furthermore, blockchain node 20h can determine the existence of the second object information based on leaf node 203b. For example, if leaf node 203b is the current state value of invoice number 8, and if leaf node 203b equals 0 (representing a state not yet on the chain), then blockchain node 20h can determine that the invoice corresponding to invoice number 8 is not yet on the chain, meaning the invoice corresponding to invoice number 8 does not exist in the blockchain. If leaf node 203b equals 1 (representing an issuance state), then blockchain node 20h can determine that the invoice corresponding to invoice number 8 is in the issuance state, and in this case, the invoice corresponding to invoice number 8 exists in the blockchain. If the root hash value to be verified is not the same as the root node of the target state tree 202d, then blockchain node 20h determines that leaf node 203b is invalid state data.

[0117] The above process describes a scenario where the second index number does not belong to the first index number. The following describes a scenario where the second index number belongs to the first index number. For example... Figure 2b As shown in the example, in the target state tree 202d, the second index number that has a mapping relationship with the second object information is set as index number 0001. Obviously, index number 0001 belongs to the first index number corresponding to the state subtree 201d. Figure 2b Examples are index numbers 0000 to 0011). At this time, consensus node 20a returns archiving prompt information 20g to blockchain node 20h, such as... Figure 2b The example “Archived, archived child root node 201c, first storage address”, where child root node 201c represents the first child root node.

[0118] After blockchain node 20h receives the archive notification information 20g, it obtains the first storage address within the archive notification information 20g. Based on the first storage address, it sends a status query request carrying the second object information to service device 20f. According to the status query request, service device 20f obtains the second index number corresponding to the second object information (e.g., ...). Figure 2b Using the second index number (0001), the first state subtree containing that second index number can be obtained (e.g., ...). Figure 2b (State subtree 201d in the context of the state subtree). Further, the service device 20f retrieves the leaf node represented by index number 0001 in state subtree 201d, such as... Figure 2b The service device 20f retrieves leaf node 205b and its verification data 20j, namely intermediate nodes 204b and 206b, which represent the hash value of the leaf node with index number 0000. The service device 20f returns both leaf node 205b and verification data 20j to the blockchain node 20h. It can be understood that after obtaining leaf node 205b and verification data 20j, the blockchain node 20h can determine the first child root node in the archived transactions broadcast in the blockchain. Figure 2b The root node 201c in the target state tree 202d performs legality and existence verification on leaf node 205b without needing to perform the same verification through the root node in the target state tree 202d. This simplifies the verification process and improves efficiency. Furthermore, the process by which the blockchain node verifies the legality and existence of leaf node 205b based on verification data 20j and root node 201c is identical to the process by which the blockchain node verifies the legality and existence of leaf node 203b based on verification data 20i and the root node in the target state tree 202d. Therefore, this process will not be elaborated upon here; please refer to the description above.

[0119] As described above, this application embodiment archives the state subtrees (e.g., the first state subtree) that meet the state archiving conditions in the target state tree. This can be understood as archiving outdated state data on the blockchain, thus reducing storage resources on the blockchain and improving the utilization rate of blockchain storage space. Furthermore, this application embodiment can use the first root node of the archived first state subtree to perform legality and existence verification on the leaf nodes (i.e., state values) belonging to the first index number, thus simplifying the verification process and improving verification efficiency.

[0120] Further, please see Figure 3 , Figure 3 This is a flowchart illustrating a blockchain-based data processing method provided in an embodiment of this application. Figure 1This blockchain-based data processing method can be executed by the blockchain's consensus nodes, by the blockchain's business nodes, or by a combination of both; no restrictions are placed here. For ease of description and understanding, this application's embodiments will be described using the consensus node as an example, where the consensus node can be one of the aforementioned... Figure 1 Any consensus node in the consensus network 10b of the corresponding embodiment. For example... Figure 3 As shown, the blockchain-based data processing method may include at least the following steps S101-S103.

[0121] Step S101: If the consensus node detects that there is a first state subtree in the target state tree that meets the state archiving conditions, then an archive transaction is generated based on the first leaf node and the first root node of the first state subtree; the first leaf node is used to represent the current state of the first object information.

[0122] Specifically, determine the total number of first leaf nodes. If the total number of first leaf nodes is equal to or greater than the archiving quantity threshold, obtain the generation timestamp of the first child root node. Determine the maintenance duration of the first child root node based on the generation timestamp. If the maintenance duration is equal to or greater than the maintenance duration threshold, determine that the first state subtree meets the state archiving conditions.

[0123] Specifically, in the target state tree, the first index number for the first leaf node is obtained; based on the first index number and the first child root node of the first state subtree, an archive transaction is generated, and the archive transaction is processed on the blockchain.

[0124] This application does not limit the type of target state tree or the object information; it can be set according to the actual application scenario.

[0125] This application proposes a data archiving scheme. It is understood that the archived state data has two characteristics: 1. The total number of archived leaf nodes (i.e., state data) must be equal to or greater than a preset archiving quantity threshold. This prevents malicious devices or blockchain nodes from traversing all leaf nodes of the archived subtree, and thus prevents malicious devices or blockchain nodes from obtaining all leaf nodes of the target state tree by colliding with the root nodes. 2. The duration for which archived leaf nodes remain unchanged is equal to or greater than a maintenance duration threshold. That is, this application embodiment archives state data when it is cold data. Please also refer to... Figure 4 , Figure 4 This is a schematic diagram of a blockchain-based data processing scenario provided in the embodiments of this application. Figure 3 .like Figure 4As shown, the consensus node generates a target state tree 40a, in which the target state tree 40a has been archived as a second state subtree. The second root node of the second state subtree is the root node 401a, and the root node 401a is associated with a second storage address, which is the address used to store the second state subtree.

[0126] The consensus node inspects the state subtrees in the target state tree 40a, for example, for... Figure 4 The first state subtree 402a in the process is detected. The specific detection process may include: the consensus node obtaining the first leaf node of the first state subtree 402a, i.e., the leaf node represented by the first index number, specifically including the leaf node represented by index number 0100, index number 0101, index number 0110, and index number 0111. The consensus node determines the total number of the first leaf nodes; in this embodiment, the total number of the first leaf nodes is 4. The consensus node compares the total number of the first leaf nodes (i.e., 4) with an archive quantity threshold. If the archive quantity threshold is greater than 4, and the total number of the first leaf nodes is less than the archive quantity threshold, then the first state subtree 402a does not meet the state archiving condition. If the archive quantity threshold is less than or equal to 4, and the total number of the first leaf nodes is equal to or greater than the archive quantity threshold, then the consensus node obtains the generation timestamp of the child root node 403a (i.e., the first child root node) of the first state subtree 402a, and determines the maintenance duration of the child root node 403a based on the generation timestamp. Furthermore, the consensus node compares the maintenance duration of the root child node 403a with the maintenance duration threshold. If the maintenance duration is less than the maintenance duration threshold, it is determined that the first state subtree 402a does not meet the state archiving condition. If the maintenance duration is equal to or greater than the maintenance duration threshold, the consensus node can determine that the first state subtree 402a meets the state archiving condition.

[0127] Understandably, consensus nodes can first compare the total number of first leaf nodes with the archive quantity threshold, or they can first compare the maintenance duration of the child root node 403a with the maintenance duration threshold, or they can perform the above two comparisons simultaneously.

[0128] Furthermore, the consensus node obtains the index number corresponding to the first leaf node of the first state subtree 402a, i.e., the first index number, such as... Figure 4 The indices are 0100 to 0111, with the first index number representing the index position of the first leaf node in the target state tree 40a. The consensus node obtains the first child root node (e.g., ...). Figure 4 The example child root node 403a) generates archived transaction 40b based on the first index number and child root node 403a, and performs on-chain processing on archived transaction 40b.

[0129] In step S102, if the archived transaction is successfully uploaded to the blockchain, the state archiving function in the smart contract is called to archive the first state subtree to the service device. The business services provided by the service device are associated with the first object information.

[0130] Specifically, archived transactions are synchronized to business nodes in the blockchain; archived transactions are used to instruct business nodes to perform legality verification on the information of the object to be verified associated with the first index number based on the first child root node.

[0131] Specifically, if the parent node of the second state subtree and the parent node of the first state subtree are the same node in the target state tree, then the second storage address of the second state subtree in the service device is obtained; the second state subtree is a state subtree in the target state tree that meets the state archiving conditions, and the archiving timestamp corresponding to the second state subtree is earlier than the archiving timestamp corresponding to the first state subtree; through the state archiving function, the parent node of the first state subtree, the first state subtree, and the second storage address are sent to the service device respectively, so that the service device writes the first state subtree and the parent node of the first state subtree according to the second storage address, and merges the first state subtree and the second state subtree to obtain a merged state subtree; the parent node of the first state subtree is the root of the merged state subtree.

[0132] Please see again. Figure 4 If archived transaction 40b is successfully uploaded to the blockchain, the consensus node will synchronize archived transaction 40b to the business nodes in the business network. This allows the business nodes to perform self-verification on the leaf nodes belonging to the first index number (i.e., index numbers 0100 to 0111) based on the child root node 403a in archived transaction 40b. The self-verification process of the business nodes is similar to that described above. Figure 2b The process of blockchain node 20h verifying leaf node 203b described in the previous section is the same, so it will not be repeated here. Please refer to the description above.

[0133] like Figure 4 As shown in the example, the second root node of the second state subtree is root node 401a, and the first root node of the first state subtree 402a is root node 403a. Root nodes 401a and 403a belong to the same parent node, namely parent node 404a. Therefore, the consensus node can obtain the second storage address associated with the second root node (i.e., root node 401a). This second storage address is the address where the second state subtree is stored on the service device. Please refer to... Figure 4 as well as Figure 5 , Figure 5 This application provides an example of a blockchain-based data processing scenario. Figure 4 .like Figure 5As shown, the consensus node calls the state archiving function 40c in the smart contract. Through the state archiving function 40c, the first state subtree 402a carrying the parent node 404a and the second storage address are sent to the service device 40e. In this embodiment, the service device 40e may include devices that provide object information (including first object information) and devices that provide business transactions containing object information. The service device 40e includes, but is not limited to, terminal devices or business servers. The business server may be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud databases, cloud services, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. Terminal devices include, but are not limited to, mobile phones, computers, smart voice interaction devices, smart home appliances, vehicle terminals, and aircraft.

[0134] After obtaining the first state subtree 402a carrying the parent node 404a and the second storage address, the service device 40e writes the first state subtree 402a and the parent node 404a according to the second storage address, such as... Figure 5 As shown, service device 40e has archived a second state subtree 40d, which includes a root node 401a and second leaf nodes, namely the leaf nodes represented by index numbers 0000 to 0011 respectively. Service device 40e merges the first state subtree 402a and the second state subtree 40d, taking the parent node 404a as the root of the merged state subtree, as shown. Figure 5 As shown in the merged state subtree 402d, it includes a first state subtree 402a, a second state subtree 40d, and a parent node 404a. It can be understood that merging two state subtrees belonging to the same parent node allows for the retrieval of both subtrees in a single read operation, avoiding two reads. This improves data retrieval efficiency and also enhances the orderliness of data archiving.

[0135] Step S103: In the target state tree, delete all nodes in the first state subtree except for the first root node; the first root node in the target state tree is used to indicate that the first state subtree has been archived.

[0136] Specifically, the first root node of the first state subtree and the second root node of the second state subtree are deleted synchronously; the parent node of the first state subtree in the target state tree is used to indicate that both the first and second state subtrees have been archived.

[0137] Please see again. Figure 4 as well as Figure 5Since the root child node 403a of the first state subtree 402a and the root child node 401a of the second state subtree 40d belong to the same parent node, namely parent node 404a, the consensus node archives the first state subtree 402a and its parent node 404a to the second storage address of the already archived second state subtree 40d. Therefore, upon receiving the archiving success information returned by the service device 40e, the consensus node 40f not only deletes the first state subtree 402a from the target state tree 40a, but also deletes the root child node 401a (i.e., the second root child node), resulting in... Figure 5 In the target state tree 40g, the second storage address is associated with the parent node 404a for storage.

[0138] As described above, this application proposes a state data archiving scheme. When the first state subtree meets the state archiving conditions, an archiving transaction is generated based on the first index number and the first root node corresponding to the first state subtree. Consensus processing is performed on the archiving transaction, and it is stored when consensus is reached. The archiving transaction is also synchronized to the business nodes. At this time, the business nodes can utilize the first root node to perform higher-performance verification of object information with fixed states. Simultaneously, all nodes in the archived first state subtree except for the first root node are deleted on the chain, thus reducing on-chain data storage pressure and alleviating storage resource burden. Furthermore, if the first root node and the second root node of the archived second state subtree belong to the same parent node, the first state subtree can be archived at the second storage address where the second state subtree is archived, ensuring the archived state data remains ordered. In subsequent read operations, both state subtrees can be read in a single read, thus improving data acquisition efficiency.

[0139] Please see Figure 6 , Figure 6 This is a second flowchart illustrating a blockchain-based data processing method provided in this application embodiment. This blockchain-based data processing method can be executed by the blockchain consensus node, by the blockchain business node, or by interaction between the consensus node and business node; no limitation is made here. For ease of description and understanding, this application embodiment uses the consensus node as an example, wherein the consensus node can be one of the aforementioned... Figure 1 Any consensus node in the consensus network 10b of the corresponding embodiment. For example... Figure 6 As shown, the method may include at least the following steps.

[0140] Step S201: If the consensus node detects that there is a first state subtree in the target state tree that meets the state archiving conditions, then an archive transaction is generated based on the first leaf node and the first root node of the first state subtree; the first leaf node is used to represent the current state of the first object information.

[0141] For the specific implementation process of step S201, please refer to the above text. Figure 3 Step S101 in the corresponding embodiment will not be described in detail here.

[0142] In step S202, if the archiving transaction is successfully uploaded to the blockchain, the business data associated with the first state subtree is obtained in the blockchain, and the state archiving function in the smart contract is called. Through the state archiving function, both the business data and the first state subtree are archived in the service device; the business services provided by the service device are associated with the first object information.

[0143] For ease of understanding, this application embodiment uses an invoice state tree as an example, that is, a Merkle tree used to record the current state of invoices. It is understood that, through the invoice state, this application embodiment can synchronously archive business data associated with the invoice state to be archived on the blockchain. Please also refer to... Figure 7 , Figure 7 This application provides an example of a blockchain-based data processing scenario. Figure 5 .like Figure 7 As shown, the first leaf node corresponding to the first state subtree 60a includes the leaf node represented by index number 0100, the leaf node represented by index number 0101, the leaf node represented by index number 0110, and the leaf node represented by index number 0111.

[0144] Among them, the leaf node represented by index number 0100 is used to represent the current state of the invoice corresponding to invoice number 5 (hereinafter referred to as invoice 5), and this leaf node is set as the first state value representing the red-inked status (e.g., Figure 7 In section 2), invoice 5 is currently in a red-inked cancellation state. The leaf node represented by index 0101 is used to represent the current state of the invoice corresponding to invoice number 6 (referred to as invoice 6). This leaf node is set as the first state value representing the red-inked cancellation state (e.g., ...). Figure 7 In section 2), invoice 6 is currently in a red-inked cancellation state. The leaf node represented by index 0110 is used to represent the current state of the invoice corresponding to invoice number 7 (referred to as invoice 7). This leaf node is set as the first state value representing the red-inked cancellation state (e.g., ...). Figure 7 In section 2), invoice 7 is currently in a red-inked state. The leaf node represented by index 0111 is used to represent the current state of the invoice corresponding to invoice number 8 (referred to as invoice 8). This leaf node is set as the second state value representing the non-existent state (e.g., ...). Figure 7 The 0 in the blockchain indicates that invoice 8 does not exist in the blockchain.

[0145] It is understood that the above descriptions are for ease of understanding of the illustrated states and state values. In actual applications, the state of an invoice may also include destruction, review, etc., and its state value can be set according to the actual application scenario. Furthermore, applications in other invoice scenarios can be understood by referring to the descriptions in the embodiments of this application.

[0146] In this embodiment, the first leaf node is set to the first level in the first state subtree 60a. That is, the first level node of the first state subtree 60a is the first leaf node, and the second level node is the state hash value obtained by hashing the first leaf node, including the state hash value H(2) of the leaf node represented by index 0100, the state hash value H(2) of the leaf node represented by index 0101, the state hash value H(2) of the leaf node represented by index 0110, and the state hash value H(0) of the leaf node represented by index 0111. The third level node of the first state subtree 60a is the merged state hash value obtained by hashing two adjacent state hash values, including the merged state hash value H(H(2)+H(2)) and the merged state hash value H(H(2)+H(0)). The fourth level node of the first state subtree 60a is the child root node, that is, the child root state hash value H(H(H(2)+H(2))+H(H(2)+H(0))).

[0147] When it is determined that the first state subtree 60a meets the state archiving conditions, the consensus node generates an archiving transaction for the first state subtree 60a, and then processes the archiving transaction on the blockchain. If the archiving transaction is successfully uploaded to the blockchain, the consensus node retrieves the business data associated with the first state subtree 60a from blockchain 60b, such as... Figure 7 The example business data 60e includes business data corresponding to invoice number 5, invoice number 6, invoice number 7, and invoice number 8. The business data corresponding to invoice number 5 may include the issuance transaction of invoice 5 (i.e., the business transaction indicating the issuance of invoice 5) and the red-inking transaction of invoice 5 (i.e., the business transaction indicating the red-inking of invoice 5). It is understood that the business data corresponding to invoice number 5 may also include data associated with the issuance transaction of invoice 5, such as read / write sets or transaction trees. The specific content of the business data can be determined according to the actual application scenario, and this embodiment does not limit it in this way.

[0148] The business data corresponding to invoice number 6 can include the issuance transaction of invoice 6, indicating the business transaction in which invoice 6 was issued, and the red-ink reversal transaction of invoice 6, indicating the business transaction in which invoice 6 was reversed. Similarly, the business data corresponding to invoice number 6 can also include data associated with the issuance transaction of invoice 6 and data associated with the red-ink reversal transaction of invoice 6. The business data corresponding to invoice number 7 can include the issuance transaction of invoice 7, indicating the business transaction in which invoice 7 was issued, and the red-ink reversal transaction of invoice 7, indicating the business transaction in which invoice 7 was reversed. Similarly, the business data corresponding to invoice number 7 can also include data associated with the issuance transaction of invoice 7 and data associated with the red-ink reversal transaction of invoice 7. It is understood that the current state of invoice 8 is that it does not exist on the blockchain; therefore, the blockchain does not currently store business data associated with invoice number 8.

[0149] Furthermore, the consensus node calls the state archiving function 60c in the smart contract, and through the state archiving function 60c, archives the business data 60e and the first state subtree 60a in the service device 60d.

[0150] Step S203: If the archiving success information for the business data and the first state subtree returned by the service device is obtained, the business data is deleted from the blockchain.

[0151] Specifically, embodiments of this application can use archived state subtrees, for example... Figure 7 The first state subtree 60a in the example is associated with business data that undergoes archiving processing. Therefore, after successful archiving, the archived business data (e.g., ...) can be stored in the blockchain. Figure 7 The business data (60e) in the blockchain is deleted. It is understandable that as the blockchain continues to operate, the amount of data it stores will increase, thus reducing the blockchain's storage space and making storage resources increasingly scarce. This embodiment of the application, by deleting outdated business data, can alleviate the storage resource burden on the blockchain and improve the utilization rate of its storage space.

[0152] Step S204: In the target state tree, delete all nodes in the first state subtree except for the first root node; the first root node in the target state tree is used to indicate that the first state subtree has been archived.

[0153] For the specific implementation process of step S204, please refer to the above text. Figure 2a The descriptions in the corresponding embodiments are not repeated here.

[0154] Furthermore, it is understood that the execution of step S204 can precede the execution of step S203, which involves deleting business data. Optionally, the execution of step S204 can be synchronized with the execution of step S203, which involves deleting business data.

[0155] Step S205: If the parent node of the second state subtree and the parent node of the first state subtree are the same node in the target state tree, then a subtree merging transaction is generated based on the second root node, the first root node and the parent node of the first state subtree of the second state subtree; the second state subtree is a state subtree in the target state tree that meets the state archiving conditions, and the archiving timestamp of the second state subtree is earlier than the archiving timestamp of the first state subtree.

[0156] This step differs from the one described above. Figure 3 Step S102 describes archiving the first state subtree that meets the state archiving conditions at the address where the already archived second state subtree is stored. This step describes the processing of the first state subtree that meets the state archiving conditions after archiving. Please also refer to... Figure 8 , Figure 8 This application provides an example of a blockchain-based data processing scenario. Figure 6 .like Figure 8 As shown, the target state tree 70a includes a second root node 701a of the second state subtree and a first root node 703a of the first state subtree. The second state subtree is archived at a second storage address, and the first state subtree is archived at a first storage address. It can be understood that the first storage address can be the same as or different from the second storage address. Furthermore, Figure 8 For the meaning of the other descriptive data in the example target state tree 70a, please refer to the description above, which will not be repeated here.

[0157] Please see again. Figure 8 Obviously, the parent node of the first child root node 703a and the parent node of the second child root node 701a are the same node in the target state tree 70a, namely the parent node 704a. At this time, the consensus node can generate the subtree merged transaction 70b based on the second child root node 701a, the first child root node 703a and the parent node 704a.

[0158] Step S206: Process the subtree merging transaction on the blockchain. If the subtree merging transaction is successfully uploaded to the blockchain, delete both the first and second child root nodes in the target state tree. The parent node of the first state subtree in the target state tree is used to indicate that both the first and second state subtrees have been archived.

[0159] Please see again. Figure 8The consensus node processes the subtree merging transaction 70b on the blockchain. If the subtree merging transaction 70b is successfully uploaded to the blockchain, the consensus node deletes the first child root node 703a and the second child root node 701a in the target state tree 70a, and associates and stores the parent node 704a, the second storage address, and the first storage address, resulting in the following: Figure 8 The example target state tree is 70c.

[0160] As described above, this application embodiment can archive the first state subtree that meets the state archiving conditions. Through archiving, the storage of old data (including the first state subtree) in the blockchain can be reduced, thus alleviating storage resources. Furthermore, this application embodiment will synchronously archive the business data associated with the first state subtree with the first state subtree, thus further reducing storage resources.

[0161] Please see Figure 9 , Figure 9 This is a flowchart illustrating a blockchain-based data processing method provided in an embodiment of this application. Figure 3 This blockchain-based data processing method can be executed by the blockchain's consensus nodes, by the blockchain's business nodes, or by a combination of both; no restrictions are placed here. For ease of description and understanding, this application's embodiments will be described using the consensus node as an example, where the consensus node can be one of the aforementioned... Figure 1 Any consensus node in the consensus network 10b of the corresponding embodiment. For example... Figure 9 As shown, the method may include at least the following steps.

[0162] Step S301: Obtain the first service information provided by the service device.

[0163] Specifically, obtain at least two pieces of business information provided by the service device; the at least two pieces of business information include the first piece of business information.

[0164] Step S302: In the smart contract, an initial state tree is constructed that includes at least two initial leaf nodes; the at least two initial leaf nodes include a first initial leaf node for the first business information; the first initial leaf node is used to indicate that there is no business transaction containing the first business information in the blockchain; the first business information includes second business information.

[0165] Specifically, the total number of information items for at least two business information items is determined, and the total number of leaf nodes is determined based on the total number of information items; in the smart contract, an initial state tree including at least two initial leaf nodes is constructed; the total number of at least two initial leaf nodes is equal to the total number of leaves; in the initial state tree, index numbers are determined to represent at least two initial leaf nodes respectively; the at least two index numbers include a first index number used to represent the first initial leaf node; a mapping relationship is constructed between the at least two index numbers and at least two business information items; wherein, a mapping relationship exists between the first index number and the first business information item.

[0166] Based on steps S301 and S302, this embodiment proposes a novel state tree. First, at least two pieces of business information provided by the service device are acquired. For ease of understanding and description, this embodiment uses invoice information as an example of business information, including but not limited to invoice number and transaction serial number. It is important to emphasize that the at least two pieces of invoice information sent by the service device do not generate corresponding invoices under the blockchain. Based on the acquired at least two pieces of invoice information, the consensus node constructs an initial state tree in the smart contract, including at least two initial leaf nodes. It can be understood that the total number of at least two initial leaf nodes is equal to or greater than the total number of at least two pieces of invoice information.

[0167] Please see also Figure 10 , Figure 10 This application provides an example of a blockchain-based data processing scenario. Figure 7 .like Figure 10 As shown, service device 90a sends at least two ticket information entries 90b to consensus node 90c. The at least two ticket information entries 90b may include ticket number 1, ticket number 2, ticket number 3, ticket number 4, ticket number 5, ticket number 6, ticket number 7, and ticket number 8. It is understood that this embodiment uses a total number of entries of 8 as an example for ease of description; in actual applications, the total number of entries can be any value.

[0168] After consensus node 90c obtains at least two ticket information entries 90b, it can generate an initial state tree 90d. Since neither of the at least two ticket information entries 90b is used to generate its corresponding ticket, the state value in each initial leaf node of the initial state tree 90d is the initial state value. Figure 10 The initial state value is 0, indicating that the ticket does not exist in the blockchain. It's understandable that the meaning of each node in the initial state tree 90d is the same as described above. Figure 7 The meaning is the same as that in the target state tree 60a, so it will not be repeated here. Please refer to the description of target state tree 60a above.

[0169] like Figure 10As shown, at least two bill information entries 90b include first bill information 90e, wherein the first bill information 90e may include bill number 1, bill number 2, bill number 3, and bill number 4. The first initial leaf node 90e may include an initial leaf node for bill number 1, an initial leaf node for bill number 2, an initial leaf node for bill number 3, and an initial leaf node for bill number 4, namely the initial leaf node represented by index number 0000, the initial leaf node represented by index number 0001, the initial leaf node represented by index number 0010, and the initial leaf node represented by index number 0011.

[0170] Step S303: Obtain the first business transaction including the second business information; based on the first business transaction, update the first initial leaf node in the initial state tree to the first leaf node; and determine the initial state tree with the updated first leaf node as the target state tree.

[0171] Specifically, the first business transaction is processed on the blockchain. If the first business transaction is successfully processed on the blockchain, the current state of the second business information is obtained based on the first business transaction. Based on the current state of the second business information, a current state value is generated to represent the current state of the second business information. The first initial leaf node is updated based on the current state value to obtain the first leaf node.

[0172] The specific process of generating a current state value to represent the current state of the second business information based on the current state of the second business information may include: if a second business transaction including the second business information is obtained within the state update cycle for the current state of the second business information, and the second business transaction is successfully uploaded to the blockchain, then an updated state to update the current state of the second business information is obtained based on the second business transaction; if the current state of the second business information is maintained within the state update cycle, then a current state value to represent the current state of the second business information is generated.

[0173] The specific process of updating the first initial leaf node based on the current state value to obtain the first leaf node may include: updating the initial state value in the first initial leaf node to the current state value; the first initial leaf node uses the initial state value to indicate that there is no business transaction containing the first business information in the blockchain; and determining the first initial leaf node with the updated current state value as the first leaf node.

[0174] Understandably, as business transactions containing ticket numbers are recorded on the blockchain, the initial state values ​​in the initial leaf nodes of the initial state tree will be updated. Please refer to [link / reference]. Figure 10Consensus node 90c obtains business transaction 90f, which is a transaction document between buyer aaaa and seller bbbb, with a transaction amount of 100 and document number 1. This document was issued on date X year D month H. This application embodiment uses business transaction 90f, which includes document number 1, as an example of a first business transaction. It can be understood that the processing procedure for other document information-related business transactions is the same as that for business transaction 90f, and therefore can be referred to.

[0175] Consensus node 90c processes business transaction 90f on the blockchain. If business transaction 90f is successfully uploaded, consensus node 90c determines the current state of bill number 1 based on business transaction 90f. This step uses the issuance status as an example to show the current state of bill number 1. Furthermore, consensus node 90c checks whether the issuance status of bill number 1 has been updated within the status update cycle. Figure 10 As shown in the example, if the issuance status of ticket number 1 remains unchanged during the status update cycle, then consensus node 90c generates a current status value to represent the issuance status of ticket number 1. Figure 10 This is an example of a state being initiated. Furthermore, consensus node 90c will use the initial state value (e.g., ...) in the initial leaf node represented by index 0000. Figure 10 The 0 in the value is updated to the current state value. Figure 10 (Taking example 1), at this time, the first initial leaf node 90e is updated to the first leaf node.

[0176] It is understandable that the state value in the leaf node can be updated before the state archiving conditions are met or before archiving is performed. Once the state archiving conditions are met or archiving is performed, the state value in the leaf node will no longer be updated.

[0177] Optionally, if consensus node 90c obtains a second business transaction (such as) including ticket number 1 during the status update period for the issuance status of ticket number 1, Figure 10 In the example shown, for business transaction 90h, consensus node 90c processes business transaction 90h on the blockchain. If business transaction 90h is successfully uploaded to the blockchain, the initial leaf node represented by index number 0000 skips the issuance state, i.e., it is not updated to the issuance state. At this time, the state update cycle detection for the red-inked state of ticket number 1 is started. The subsequent processing is the same as the processing of business transaction 90f by consensus node 90c, so it will not be described in detail.

[0178] To reiterate, the embodiments in this application are for ease of understanding. The example of bill number 1 represents the second business information, and business transaction 90f represents the first business transaction. The status updates for other bill information can be found in the above description and will not be repeated here. Furthermore, in practical applications, some bills are not recorded on the blockchain. Therefore, in this case, the blockchain status for bills not recorded on the blockchain is "no blockchain exists."

[0179] Step S304: If the system time reaches the tree root update cycle, then obtain the target tree root of the target state tree; the target tree root is different from the initial tree root of the initial state tree.

[0180] Step S305: Based on the system time and the target tree root, generate a tree root publishing transaction and process the tree root publishing transaction on the blockchain.

[0181] Step S306: If the root of the tree successfully publishes the transaction on the chain, then according to the target state tree, generate synchronization data for the business node and synchronize the synchronization data to the business node; the business node belongs to the blockchain.

[0182] Specifically, in the target state tree, the synchronization leaf node with synchronization permission of the business node is obtained, and the state verification path corresponding to the synchronization leaf node is obtained; based on the synchronization leaf node, the state verification path and the root of the tree, the transaction is published, and synchronization data is generated; the synchronization data is used to instruct the business node to perform legality verification on the synchronization leaf node according to the target root of the tree and the state verification path in the transaction published by the root of the tree.

[0183] It is understandable that since leaf nodes can be updated before archiving, the state verification path of a leaf node can change, but the state verification path of a leaf node after archiving is not updated.

[0184] Step S307: If a first state subtree that satisfies the state archiving conditions is detected in the target state tree, an archived transaction is generated based on the first leaf node and the first root node of the first state subtree.

[0185] Step S308: If the archived transaction is successfully uploaded to the blockchain, the state archiving function in the smart contract is called to archive the first state subtree to the service device; the business services provided by the service device are associated with the first business information.

[0186] Step S309: In the target state tree, delete all nodes in the first state subtree except for the first root node; the first root node in the target state tree is used to indicate that the first state subtree has been archived.

[0187] For details on the implementation of steps S307-S309, please refer to the above text. Figure 3Steps S101-S103 in the corresponding embodiments will not be described in detail here.

[0188] It is understood that the embodiments involved in this application, such as Figure 2a , Figure 2b , Figure 3 , Figure 6 as well as Figure 9 The respective embodiments can be combined to generate new embodiments.

[0189] As can be seen from the above, the embodiments of this application can perform archiving processing on the first state subtree that meets the state archiving conditions. Through archiving processing, the storage of old data (including the first state subtree) in the blockchain can be reduced, thus alleviating storage resources.

[0190] Further, please see Figure 11 , Figure 11 This is a schematic diagram of a blockchain-based data processing device provided in an embodiment of this application. This blockchain-based data processing device can operate on a consensus node, which belongs to the blockchain. The aforementioned blockchain-based data processing device 1 can be used to execute the corresponding steps in the method provided in the embodiment of this application. Figure 11 As shown, the blockchain-based data processing device 1 may include: a first generation module 11, a status archiving module 12, and a first deletion module 13.

[0191] The first generation module 11 is used to generate archived transactions based on the first leaf node and the first root node of the first state subtree if the consensus node detects that there is a first state subtree in the target state tree that meets the state archiving conditions; the first leaf node is used to represent the current state of the first object information.

[0192] The state archiving module 12 is used to call the state archiving function in the smart contract if the archived transaction is successfully uploaded to the chain. Through the state archiving function, the first state subtree is archived in the service device; the business services provided by the service device are associated with the first object information.

[0193] The first deletion module 13 is used to delete nodes in the first state subtree except for the first root node in the target state tree; the first root node in the target state tree is used to indicate that the first state subtree has been archived.

[0194] The specific functional implementations of the first generation module 11, the status archiving module 12, and the first deletion module 13 can be found above. Figure 3 Steps S101-S103 in the corresponding embodiment will not be described again here.

[0195] Please see again Figure 11The blockchain-based data processing device 1 may further include: a first determining module 14 and a second determining module 15.

[0196] The first determining module 14 is used to determine the total number of the first leaf nodes. If the total number of the first leaf nodes is equal to or greater than the archived number threshold, the generation timestamp of the first child root node is obtained.

[0197] The second determining module 15 is used to determine the maintenance duration of the first child root node based on the generated timestamp. If the maintenance duration is equal to or greater than the maintenance duration threshold, then the first state subtree is determined to meet the state archiving condition.

[0198] The specific functional implementation methods of the first determining module 14 and the second determining module 15 can be found in the above description. Figure 3 Step S101 in the corresponding embodiment will not be described again here.

[0199] Please see again Figure 11 The first generation module 11 may include a first acquisition unit 111 and a first generation unit 112.

[0200] The first acquisition unit 111 is used to acquire the first index number for the first leaf node in the target state tree;

[0201] The first generation unit 112 is used to generate archived transactions based on the first index number and the first child root node of the first state subtree, and to process the archived transactions on the blockchain.

[0202] The blockchain-based data processing device may further include: a first synchronization module 16.

[0203] The first synchronization module 16 is used to synchronize archived transactions to business nodes in the blockchain; the archived transactions are used to instruct business nodes to perform legality verification on the information of the object to be verified associated with the first index number according to the first child root node.

[0204] The specific functional implementations of the first acquisition unit 111, the first generation unit 112, and the first synchronization module 16 can be found in the above description. Figure 3 Step S101 in the corresponding embodiment will not be described again here.

[0205] Please see again Figure 11 The blockchain-based data processing device 1 may further include: a second generation module 17 and a second deletion module 18.

[0206] The second generation module 17 is used to generate a subtree merging transaction based on the second root node, the first root node, and the parent node of the first subtree if the parent node of the second state subtree and the parent node of the first state subtree are the same node in the target state tree; the second state subtree is a state subtree in the target state tree that meets the state archiving conditions, and the archiving timestamp of the second state subtree is earlier than the archiving timestamp of the first state subtree.

[0207] The second deletion module 18 is used to process the subtree merging transaction on the blockchain. If the subtree merging transaction is successfully uploaded to the blockchain, the first child root node and the second child root node are deleted in the target state tree. The parent node of the first state subtree in the target state tree is used to indicate that the first state subtree and the second state subtree have been archived.

[0208] The specific functional implementation methods of the second generation module 17 and the second deletion module 18 can be found in the above description. Figure 6 Steps S205-S206 in the corresponding embodiment will not be described again here.

[0209] Please see again Figure 11 The state archiving function has the function of calling back the first storage address of the first state subtree when the service device successfully stores the first state subtree, and has the function of associating the first storage address with the first child root node.

[0210] The blockchain-based data processing device 1 may further include: a first acquisition module 19 and an archiving prompt module 20.

[0211] The first acquisition module 19 is used to acquire a status query request carrying second object information sent by a blockchain node, and determine a second index number that has a mapping relationship with the second object information in the target state tree according to the status query request.

[0212] The archiving prompt module 20 is used to return archiving prompt information carrying the first storage address and the first child root node to the blockchain node if the second index number belongs to the first index number for the first leaf node in the target state tree. The archiving prompt information is used to instruct the blockchain node to query the first state subtree in the service device according to the first storage address, and to obtain the leaf node corresponding to the second object information in the first state subtree. The first child root node is used to verify the legality of the leaf node corresponding to the second object information.

[0213] The specific functional implementation methods of the first acquisition module 19 and the archiving prompt module 20 can be found in the above description. Figure 2b The corresponding implementation examples will not be described in detail here.

[0214] Please see again Figure 11 The status archiving module 12 may include a second acquisition unit 121 and an address sending unit 122.

[0215] The second acquisition unit 121 is used to acquire the second storage address of the second state subtree in the service device if the parent node to which the second state subtree belongs and the parent node to which the first state subtree belongs are the same node in the target state tree; the second state subtree is a state subtree in the target state tree that meets the state archiving conditions, and the archiving timestamp corresponding to the second state subtree is earlier than the archiving timestamp corresponding to the first state subtree.

[0216] Address sending unit 122 is used to send the parent node of the first state subtree, the first state subtree, and the second storage address to the service device through a state archiving function, so that the service device writes the first state subtree and the parent node of the first state subtree according to the second storage address, and merges the first state subtree and the second state subtree to obtain a merged state subtree; the parent node of the first state subtree is the root of the merged state subtree.

[0217] The first deletion module 13 is also used to synchronously delete the first child root node of the first state subtree and the second child root node of the second state subtree; the parent node of the first state subtree in the target state tree is used to indicate that both the first state subtree and the second state subtree have been archived.

[0218] The specific functional implementations of the second acquisition unit 121, the address sending unit 122, and the first deletion module 13 can be found above. Figure 3 Step S102 in the corresponding embodiment will not be described again here.

[0219] Please see again Figure 11 The state archiving module 12 is specifically used to obtain business data associated with the first state subtree in the blockchain, and archive both the business data and the first state subtree in the service device through the state archiving function.

[0220] The first deletion module 13 is also used to delete the business data in the blockchain if it receives successful archiving information for the business data and the first state subtree returned by the service device.

[0221] The specific functional implementation methods of the status archiving module 12 and the first deletion module 13 can be found in the above description. Figure 6 Steps S202-S203 in the corresponding embodiment will not be described again here.

[0222] Please see again Figure 11 The first object information includes the first business information;

[0223] The blockchain-based data processing device 1 may further include: a second acquisition module 21, a state initialization module 22, a third acquisition module 23, and a third determination module 24.

[0224] The second acquisition module 21 is used to acquire the first service information provided by the service device;

[0225] The state initialization module 22 is used to construct an initial state tree in a smart contract, including at least two initial leaf nodes; the at least two initial leaf nodes include a first initial leaf node for the first business information; the first initial leaf node is used to indicate that there is no business transaction containing the first business information in the blockchain; the first business information includes second business information;

[0226] The third acquisition module 23 is used to acquire the first business transaction including the second business information, and update the first initial leaf node in the initial state tree to the first leaf node according to the first business transaction.

[0227] The third determining module 24 is used to determine the initial state tree with the first leaf node as the target state tree.

[0228] The specific functional implementations of the second acquisition module 21, the state initialization module 22, the third acquisition module 23, and the third determination module 24 can be found above. Figure 9 Steps S301-S303 in the corresponding embodiment will not be described again here.

[0229] Please see again Figure 11 The second acquisition module 21 is specifically used to acquire at least two pieces of service information provided by the service device; the at least two pieces of service information include the first piece of service information.

[0230] The state initialization module 22 may include: a first determination unit 221, a state initialization unit 222, a third acquisition unit 223, and a second determination unit 224.

[0231] The first determining unit 221 is used to determine the total number of information items for at least two business information items, and to determine the total number of leaves based on the total number of information items;

[0232] State initialization unit 222 is used in a smart contract to construct an initial state tree including at least two initial leaf nodes; the total number of at least two initial leaf nodes is equal to the total number of leaves.

[0233] The third acquisition unit 223 is used to determine, in the initial state tree, index numbers used to characterize at least two initial leaf nodes respectively; the at least two index numbers include a first index number used to characterize the first initial leaf node;

[0234] The second determining unit 224 is used to construct a mapping relationship for at least two index numbers and at least two business information; wherein, there is a mapping relationship between the first index number and the first business information.

[0235] The specific functional implementation methods of the first determining unit 221, the state initializing unit 222, the third acquiring unit 223, and the second determining unit 224 can be found above. Figure 9 Steps S301-S302 in the corresponding embodiment will not be described again here.

[0236] Please see again Figure 11 The third acquisition module 23 may include: a fourth acquisition unit 231, a second generation unit 232, and a node update unit 233.

[0237] The fourth acquisition unit 231 is used to process the first business transaction on the blockchain. If the first business transaction is successfully uploaded to the blockchain, the current status of the second business information is obtained based on the first business transaction.

[0238] The second generation unit 232 is used to generate a current state value that represents the current state of the second business information based on the current state of the second business information.

[0239] The node update unit 233 is used to update the first initial leaf node according to the current state value to obtain the first leaf node.

[0240] The specific functional implementation methods of the fourth acquisition unit 231, the second generation unit 232, and the node update unit 233 can be found above. Figure 9 Step S303 in the corresponding embodiment will not be described again here.

[0241] Please see again Figure 11 The second generation unit 232 may include: a first update subunit 2321 and a current generation subunit 2322.

[0242] The first update subunit 2321 is used to obtain the update state for updating the current state of the second business information if a second business transaction including the second business information is obtained within the state update cycle of the current state of the second business information and the second business transaction is successfully uploaded to the chain, based on the second business transaction.

[0243] The current generation subunit 2322 is used to generate a current state value that represents the current state of the second business information if the current state of the second business information is maintained during the state update cycle.

[0244] The specific functional implementation methods of the first updating subunit 2321 and the current generating subunit 2322 can be found above. Figure 9Step S303 in the corresponding embodiment will not be described again here.

[0245] Please see again Figure 11 The node update unit 233 may include: a second update subunit 2331 and a node determination subunit 2332.

[0246] The second update subunit 2331 is used to update the initial state value in the first initial leaf node to the current state value; the first initial leaf node uses the initial state value to indicate that there is no business transaction containing the first business information in the blockchain;

[0247] The node determination subunit 2332 is used to determine the first initial leaf node with the updated current state value as the first leaf node.

[0248] The specific functional implementation methods of the second update subunit 2331 and the node determination subunit 2332 can be found above. Figure 9 Step S303 in the corresponding embodiment will not be described again here.

[0249] Please see again Figure 11 The blockchain-based data processing device 1 may further include: a fourth acquisition module 25, a third generation module 26, and a second synchronization module 27.

[0250] The fourth acquisition module 25 is used to acquire the target tree root of the target state tree if the system time reaches the tree root update cycle; the target tree root is different from the initial tree root of the initial state tree.

[0251] The third generation module 26 is used to generate tree root publishing transactions based on the system time and the target tree root, and to process the tree root publishing transactions on the blockchain.

[0252] The second synchronization module 27 is used to generate synchronization data for business nodes based on the target state tree if the transaction published by the root of the tree is successfully uploaded to the chain, and then synchronize the synchronization data to the business nodes; the business nodes belong to the blockchain.

[0253] The specific functional implementation methods of the fourth acquisition module 25, the third generation module 26, and the second synchronization module 27 can be found above. Figure 9 Steps S304-S306 in the corresponding embodiment will not be described again here.

[0254] Please see again Figure 11 The second synchronization module 27 may include a fifth acquisition unit 271 and a third generation unit 272.

[0255] The fifth acquisition unit 271 is used to acquire, in the target state tree, the synchronization leaf node with synchronization permission of the business node, and the state verification path corresponding to the synchronization leaf node.

[0256] The third generation unit 272 is used to generate synchronization data based on the synchronization leaf node, the state verification path, and the root of the transaction. The synchronization data is used to instruct the business node to perform legality verification on the synchronization leaf node based on the target root of the transaction and the state verification path.

[0257] The specific functional implementation methods of the fifth acquisition unit 271 and the third generation unit 272 can be found in the above description. Figure 9 Step S306 in the corresponding embodiment will not be described again here.

[0258] In this embodiment, if a first state subtree satisfying the state archiving conditions is detected in the target state tree, an archiving transaction can be generated based on the first leaf node and the first root node of the first state subtree. The first leaf node represents the current state of the first object information. If the archiving transaction is successfully uploaded to the blockchain, the state archiving function in the smart contract is called. Through this function, the first state subtree can be archived on the service device, where the business services provided by the service device are associated with the first object information. Simultaneously, in the target state tree, all nodes in the first state subtree except the first root node are deleted. At this point, the first root node in the target state tree indicates that the first state subtree has been archived. As can be seen from the above, this embodiment can archive first state subtrees that satisfy the state archiving conditions. This archiving process reduces the storage of old data (including the first state subtree) in the blockchain, thus alleviating storage resource requirements.

[0259] Further, please see Figure 12 , Figure 12 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Figure 12 As shown, the computer device 1000 may include: at least one processor 1001, such as a CPU, at least one network interface 1004, a user interface 1003, a memory 1005, and at least one communication bus 1002. The communication bus 1002 is used to implement communication between these components. In some embodiments, the user interface 1003 may include a display screen and a keyboard, and the network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 1005 may be high-speed RAM or non-volatile memory, such as at least one disk drive. Optionally, the memory 1005 may also be at least one storage device located remotely from the aforementioned processor 1001. Figure 12As shown, the memory 1005, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a device control application program.

[0260] exist Figure 12 In the computer device 1000 shown, the network interface 1004 provides network communication functionality; the user interface 1003 is mainly used to provide an input interface for the user; and the processor 1001 can be used to call the device control application stored in the memory 1005 to achieve:

[0261] If a first state subtree that satisfies the state archiving conditions is detected in the target state tree, an archived transaction is generated based on the first leaf node and the first root node of the first state subtree; the first leaf node is used to represent the current state of the first object information.

[0262] If the archived transaction is successfully uploaded to the blockchain, the state archiving function in the smart contract is called. Through the state archiving function, the first state subtree is archived in the service device; the business services provided by the service device are associated with the first object information.

[0263] In the target state tree, all nodes in the first state subtree except the first root node are deleted; the first root node in the target state tree is used to indicate that the first state subtree has been archived.

[0264] It should be understood that the computer device 1000 described in the embodiments of this application can perform the data processing methods or apparatus based on blockchain described in the preceding embodiments, and will not be repeated here. In addition, the beneficial effects of using the same method will also not be repeated.

[0265] This application also provides a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the blockchain-based data processing methods or apparatus described in the preceding embodiments, which will not be repeated here. Furthermore, the beneficial effects of using the same method will also not be repeated.

[0266] The aforementioned computer-readable storage medium can be the internal storage unit of the blockchain-based data processing apparatus provided in any of the foregoing embodiments or the computer device, such as the hard drive or memory of the computer device. The computer-readable storage medium can also be an external storage device of the computer device, such as a plug-in hard drive, smart media card (SMC), secure digital (SD) card, flash card, etc., provided on the computer device. Furthermore, the computer-readable storage medium can include both internal and external storage units of the computer device. The computer-readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer-readable storage medium can also be used to temporarily store data that has been output or will be output.

[0267] This application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium and executes the computer program, enabling the computer device to perform the blockchain-based data processing methods or apparatus described in the preceding embodiments, which will not be repeated here. Furthermore, the beneficial effects of using the same method will also not be repeated.

[0268] The terms "first," "second," etc., in the specification, claims, and drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the term "comprising," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, apparatus, product, or device that includes a series of steps or units is not limited to the listed steps or modules, but may optionally include steps or modules not listed, or may optionally include other step units inherent to these processes, methods, apparatuses, products, or devices.

[0269] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this application.

[0270] The above-disclosed embodiments are merely preferred embodiments of this application and should not be construed as limiting the scope of this application. Therefore, any equivalent variations 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 blockchain, characterized in that, include: If a consensus node detects that there is a first state subtree in the target state tree that meets the state archiving conditions, it generates an archived transaction based on the first leaf node and the first root node of the first state subtree. The target state tree is used to store the current state of all object information, and the target state tree is obtained by updating the initial leaf nodes in the initial state tree. The first leaf node is used to represent the current state of the first object information. If the archived transaction is successfully uploaded to the blockchain, the state archiving function in the smart contract is called, and the first state subtree is archived to the service device through the state archiving function. The service provided by the service device is associated with the first object information; In the target state tree, all nodes in the first state subtree except the first root node are deleted; The first sub-root node in the target state tree is used to indicate that the first state subtree has been archived.

2. The method according to claim 1, characterized in that, The method further includes: Determine the total number of the first leaf nodes. If the total number of the first leaf nodes is equal to or greater than the archived number threshold, obtain the generation timestamp of the first child root node. The maintenance duration of the first child root node is determined based on the generated timestamp. If the maintenance duration is equal to or greater than the maintenance duration threshold, then the first state subtree is determined to satisfy the state archiving condition.

3. The method according to claim 1, characterized in that, The step of generating archived transactions based on the first leaf node and the first root node of the first state subtree includes: In the target state tree, obtain the first index number for the first leaf node; Based on the first index number and the first root node of the first state subtree, an archive transaction is generated, and the archive transaction is processed on the blockchain. The method further includes: The archived transaction is synchronized to the business nodes in the blockchain; the archived transaction is used to instruct the business nodes to perform legality verification on the object information to be verified associated with the first index number according to the first child root node.

4. The method according to claim 1, characterized in that, The method further includes: If the parent node of the second state subtree and the parent node of the first state subtree are the same node in the target state tree, then a subtree merging transaction is generated based on the second root node of the second state subtree, the first root node, and the parent node of the first state subtree; the second state subtree is a state subtree in the target state tree that satisfies the state archiving condition, and the archiving timestamp corresponding to the second state subtree is earlier than the archiving timestamp corresponding to the first state subtree; The subtree merging transaction is processed on the blockchain. If the subtree merging transaction is successfully processed on the blockchain, the first child root node and the second child root node are deleted from the target state tree. The parent node of the first state subtree in the target state tree is used to indicate that the first state subtree and the second state subtree have been archived.

5. The method according to claim 1, characterized in that, The state archiving function has the function of calling back the first storage address of the first state subtree when the service device successfully stores the first state subtree, and has the function of storing the first storage address and the first child root node together. The method further includes: Obtain a status query request sent by a blockchain node carrying information about a second object; and determine a second index number in the target state tree that has a mapping relationship with the information about the second object based on the status query request. If the second index number belongs to the first index number for the first leaf node in the target state tree, then an archiving prompt message carrying the first storage address and the first child root node is returned to the blockchain node; the archiving prompt message is used to instruct the blockchain node to query the first state subtree in the service device according to the first storage address, and to obtain the leaf node corresponding to the second object information in the first state subtree; the first child root node is used to verify the legality of the leaf node corresponding to the second object information.

6. The method according to claim 1, characterized in that, The step of archiving the first state subtree to the service device through the state archiving function includes: If the parent node of the second state subtree and the parent node of the first state subtree are the same node in the target state tree, then the second storage address of the second state subtree in the service device is obtained; the second state subtree is a state subtree in the target state tree that meets the state archiving conditions, and the archiving timestamp corresponding to the second state subtree is earlier than the archiving timestamp corresponding to the first state subtree. The state archiving function sends the parent node of the first state subtree, the first state subtree, and the second storage address to the service device, so that the service device writes the first state subtree and the parent node of the first state subtree according to the second storage address, and merges the first state subtree and the second state subtree to obtain a merged state subtree; the parent node of the first state subtree is the root of the merged state subtree. The method further includes: The first root node of the first state subtree and the second root node of the second state subtree are deleted synchronously; the parent node of the first state subtree in the target state tree is used to indicate that both the first state subtree and the second state subtree have been archived.

7. The method according to claim 1, characterized in that, The step of archiving the first state subtree to the service device through the state archiving function includes: In the blockchain, business data associated with the first state subtree is obtained, and the business data and the first state subtree are archived in the service device through a state archiving function. The method further includes: If the service device returns successful archiving information for the business data and the first state subtree, then the business data is deleted from the blockchain.

8. The method according to claim 1, characterized in that, The first object information includes the first business information; The method further includes: Obtain the first service information provided by the service device; In the smart contract, an initial state tree is constructed, including at least two initial leaf nodes; the at least two initial leaf nodes include a first initial leaf node for the first business information; the first initial leaf node is used to indicate that there is no business transaction containing the first business information in the blockchain; the first business information includes second business information; Obtain a first business transaction including the second business information, and update the first initial leaf node in the initial state tree to the first leaf node according to the first business transaction; The initial state tree that is updated with the first leaf node is determined as the target state tree.

9. The method according to claim 8, characterized in that, The step of obtaining the first service information provided by the service device includes: Obtain at least two pieces of service information provided by the service device; the at least two pieces of service information include the first piece of service information. The construction of an initial state tree, including at least two initial leaf nodes, within the smart contract includes: Determine the total number of information items for the at least two business information items, and determine the total number of leaves based on the total number of information items; In the smart contract, an initial state tree is constructed, including at least two initial leaf nodes; the total number of the at least two initial leaf nodes is equal to the total number of leaves. In the initial state tree, index numbers are determined to represent the at least two initial leaf nodes; the at least two index numbers include a first index number used to represent the first initial leaf node; A mapping relationship is constructed for the at least two index numbers and the at least two business information; wherein, a mapping relationship exists between the first index number and the first business information.

10. The method according to claim 8, characterized in that, The step of updating the first initial leaf node in the initial state tree to the first leaf node according to the first business transaction includes: The first business transaction is processed on the blockchain. If the first business transaction is successfully processed on the blockchain, the current status of the second business information is obtained based on the first business transaction. Based on the current state of the second business information, generate a current state value to represent the current state of the second business information; The first initial leaf node is updated based on the current state value to obtain the first leaf node.

11. The method according to claim 10, characterized in that, The step of generating a current state value to characterize the current state of the second service information based on the current state of the second service information includes: If a second business transaction including the second business information is obtained within the status update period of the current status of the second business information, and the second business transaction is successfully uploaded to the chain, then based on the second business transaction, an update status for updating the current status of the second business information is obtained. If the current state of the second service information is maintained within the state update cycle, a current state value is generated to characterize the current state of the second service information.

12. The method according to claim 10, characterized in that, The step of updating the first initial leaf node based on the current state value to obtain the first leaf node includes: The initial state value in the first initial leaf node is updated to the current state value; the first initial leaf node uses the initial state value to indicate that there is no business transaction containing the first business information in the blockchain; The first initial leaf node with the current state value will be updated and determined as the first leaf node.

13. The method according to claim 8, characterized in that, The method further includes: If the system time reaches the root update cycle, the target root of the target state tree is obtained; the target root is different from the initial root of the initial state tree. Based on the system time and the target tree root, a tree root publishing transaction is generated, and the tree root publishing transaction is processed on the blockchain. If the transaction published by the root of the tree is successfully uploaded to the blockchain, then according to the target state tree, synchronization data for the business node is generated and synchronized to the business node; the business node belongs to the blockchain.

14. The method according to claim 13, characterized in that, The step of generating synchronization data for business nodes based on the target state tree includes: In the target state tree, obtain the synchronization leaf node that the business node has synchronization permission, and obtain the state verification path corresponding to the synchronization leaf node; Synchronization data is generated based on the synchronized leaf node, the state verification path, and the root-published transaction; the synchronization data is used to instruct the business node to perform legality verification on the synchronized leaf node based on the target root and the state verification path in the root-published transaction.

15. A data processing device based on blockchain, characterized in that, The blockchain-based data processing device operates on a consensus node and includes: The first generation module is used to generate an archived transaction based on the first leaf node and the first root node of the first state subtree if a first state subtree satisfying the state archiving conditions is detected in the target state tree; the target state tree is used to store the current state of all object information, and the target state tree is obtained by updating the initial leaf nodes in the initial state tree; the first leaf node is used to represent the current state of the first object information. The state archiving module is used to call the state archiving function in the smart contract if the archived transaction is successfully uploaded to the chain, and archive the first state subtree to the service device through the state archiving function; the business services provided by the service device are associated with the first object information. The state deletion module is used to delete nodes in the first state subtree except for the first root node in the target state tree; the first root node in the target state tree is used to indicate that the first state subtree has been archived.

16. A computer device, characterized in that, include: Processor, memory, and network interface; The processor is connected to the memory and the network interface, wherein the network interface is used to provide data communication functions, the memory is used to store computer programs, and the processor is used to invoke the computer programs to cause the computer device to perform the method according to any one of claims 1 to 14.

17. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program adapted to be loaded and executed by a processor to cause a computer device having the processor to perform the method of any one of claims 1-14.

18. A computer program product, characterized in that, The computer program product includes a computer program stored in a computer-readable storage medium, the computer program being adapted to be read and executed by a processor to cause a computer device having the processor to perform the method of any one of claims 1-14.