Blockchain-based data processing method, apparatus, device, and readable storage medium
By executing transactions and generating zero-knowledge proof data in the sub-blockchain network, the problems of insufficient TPS and excessive storage pressure in the main blockchain network are solved, achieving faster transaction confirmation and more efficient storage management.
Patent Information
- Application Number
- CN202210047963.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-17
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2042-01-17
AI Technical Summary
Existing blockchain networks have limited TPS (transactions per second), resulting in long transaction waiting times, excessive storage pressure, and the risk of data bloat.
By executing transaction data in the sub-blockchain network through relay nodes, zero-knowledge proof data is generated and submitted to the main chain node for verification. After the main chain node passes the verification, it updates the main chain account status based on the status change information, thereby reducing the transaction execution volume of the main chain node.
It improved the TPS of the main blockchain network, alleviated storage pressure, and solved the problems of slow transaction confirmation and storage overload.
Smart Images

Figure CN116488818B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a data processing method, apparatus, device, and readable storage medium based on blockchain. Background Technology
[0002] Blockchain is a novel application model of computer technologies, including distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. It is primarily used to organize data chronologically and encrypt it into a ledger, making it tamper-proof and forgery-proof. It also enables data verification, storage, and updating. Blockchain can also perform encrypted data transmission, node identification, and secure access, making it an advanced distributed infrastructure. Currently, due to its immutability and authenticity, blockchain applications are increasingly prevalent.
[0003] Digital products can circulate on the blockchain through transactions, but the TPS (Transactions Per Second) of existing blockchain networks is limited. When the number of transactions related to digital products is too large, it will cause problems such as long on-chain transaction waiting time and slow transaction confirmation. In addition, too much transaction data that needs to be stored on the blockchain will also lead to excessive storage pressure on the blockchain, which in turn will trigger the risk of data expansion on the blockchain. Summary of the Invention
[0004] This application provides a data processing method, apparatus, device, and readable storage medium based on blockchain, which can improve the TPS of the blockchain network and alleviate the storage pressure of the blockchain network.
[0005] One embodiment of this application provides a blockchain-based data processing method, including:
[0006] Relay nodes execute transaction data for the target subchain account and obtain the transaction execution result; relay nodes belong to the subchain network;
[0007] Obtain the total account status data in the sub-blockchain network, and generate the total account status data to be verified based on the transaction execution results and the total account status data; the total account status data includes the status data of at least two sub-chain accounts, and the at least two sub-chain accounts include the target sub-chain account;
[0008] Generate zero-knowledge proof data based on the total account status data and the total account status data to be verified.
[0009] The zero-knowledge proof data and the state change information associated with the transaction execution result are submitted to a main chain node, so that the main chain node changes the state data of a target main chain account according to the state change information when the zero-knowledge proof data is proved to be valid; the target sub-chain account is associated with the target main chain account; and the main chain node belongs to a main blockchain network.
[0010] The embodiment of the application provides a data processing method based on a blockchain, which comprises the following steps:
[0011] The main chain node receives the zero-knowledge proof data and the state change information associated with the transaction execution result submitted by the relay node; the main chain node belongs to a main blockchain network; the relay node belongs to a sub-blockchain network; the zero-knowledge proof data is generated according to the total state data of the account in the sub-blockchain network and the to-be-verified total state data of the account; the to-be-verified total state data of the account is generated according to the transaction execution result and the total state data of the account; and the transaction execution result is obtained by executing the transaction data for the target sub-chain account by the relay node.
[0012] The proof contract is called to prove and verify the zero-knowledge proof data, and a proof verification result is obtained.
[0013] If the proof verification result is a proof verification pass result, the state data of the target main chain account is changed according to the state change information; the target sub-chain account is associated with the target main chain account.
[0014] The embodiment of the application provides a data processing device based on a blockchain, which comprises the following steps:
[0015] The execution module is configured to execute the transaction data for the target sub-chain account, and obtain a transaction execution result; the relay node belongs to a sub-blockchain network.
[0016] The state generation module is configured to obtain the total state data of the account in the sub-blockchain network, and generate the to-be-verified total state data of the account according to the transaction execution result and the total state data of the account; the total state data of the account comprises the state data of at least two sub-chain accounts, and the at least two sub-chain accounts comprise the target sub-chain account.
[0017] The proof generation module is configured to generate the zero-knowledge proof data according to the total state data of the account and the to-be-verified total state data of the account.
[0018] The submission module is configured to submit the zero-knowledge proof data and the state change information associated with the transaction execution result to a main chain node, so that the main chain node changes the state data of a target main chain account according to the state change information when the zero-knowledge proof data is proved to be valid; the target sub-chain account is associated with the target main chain account; and the main chain node belongs to a main blockchain network.
[0019] The proof generation module comprises:
[0020] a first hashing unit, configured to hash the total account state data to obtain a first state hash value;
[0021] a second hashing unit, configured to hash the total account state data to obtain a second state hash value;
[0022] a change determining unit, configured to determine state data change values corresponding to the at least two sub-chain accounts respectively according to the total account state data and the total account state data to be verified;
[0023] a proof generating unit, configured to input the first state hash value, the second state hash value and the state data change values into a zero-knowledge proof circuit to obtain zero-knowledge proof data.
[0024] The first hashing unit comprises:
[0025] an account hashing sub-unit, configured to hash the state data of the at least two sub-chain accounts in the total account state data respectively to obtain account state hash values corresponding to the at least two sub-chain accounts respectively;
[0026] a tree hashing sub-unit, configured to hash the account state hash values corresponding to the at least two sub-chain accounts respectively according to the state Merkle tree path to obtain a root hash value, and determine the root hash value as the first state hash value.
[0027] The data processing apparatus further comprises:
[0028] a packing module, configured to pack the transaction data into the sub-chain block to be chained;
[0029] a consensus module, configured to perform consensus processing on the sub-chain block to be chained after the zero-knowledge proof data is proved and verified by the main-chain node;
[0030] an updating module, configured to update the total account state data in the account ledger of the sub-blockchain network to the total account state data to be verified when the consensus processing on the sub-chain block to be chained is passed.
[0031] Embodiment one of the present application provides a data processing apparatus based on a blockchain, comprising:
[0032] a receiving module, configured to receive zero-knowledge proof data submitted by a relay node and state change information associated with a transaction execution result; the main-chain node belongs to a main blockchain network; the relay node belongs to a sub-blockchain network; the zero-knowledge proof data is generated according to total account state data of the sub-blockchain network and total account state data to be verified; the total account state data to be verified is generated according to a transaction execution result and the total account state data; and the transaction execution result is obtained by the relay node executing transaction data for a target sub-chain account.
[0033] The proof verification module is configured to invoke the proof contract to perform proof verification on the zero-knowledge proof data, and obtain a proof verification result.
[0034] The changing module is configured to change the state data of the target main chain account according to the state change information if the proof verification result is a proof verification pass result. The target sub-chain account is associated with the target main chain account.
[0035] The state data of the target main chain account includes on-chain state data and contract state data of the target main chain account. The on-chain state data is used to represent on-chain virtual resources owned by the target main chain account in the main blockchain network and not locked in the resource locking contract. The contract state data is used to represent contract virtual resources owned by the target main chain account in the main blockchain network and locked in the resource locking contract.
[0036] The changing module includes:
[0037] The first changing unit is configured to perform state change on the on-chain state data and the contract state data of the target main chain account according to the state change information if the transaction data belongs to the first transaction business type.
[0038] The second changing unit is configured to perform state change on the contract state data of the target main chain account according to the state change information if the transaction data belongs to the second transaction business type.
[0039] The first transaction business type is a storage business type, and the state change information includes the target main chain account used to execute the storage business and target storage state data.
[0040] The first changing unit includes:
[0041] The first transfer sub-unit is configured to obtain virtual resources corresponding to the target storage state data as storage virtual resources from on-chain virtual resources corresponding to the target main chain account if the transaction data belongs to the storage business type.
[0042] The first transfer sub-unit is further configured to transfer the storage virtual resources to the resource locking contract for locking.
[0043] The storage changing sub-unit is configured to subtract the on-chain state data from the target storage state data to obtain state-changed on-chain state data.
[0044] The storage changing sub-unit is further configured to add the contract state data to the target storage state data to obtain state-changed contract state data.
[0045] The first transaction business type is a withdrawal business type, and the state change information includes a target main chain account used for performing the withdrawal business and target withdrawal state data.
[0046] The first change unit comprises:
[0047] The second transfer subunit is configured to, if the transaction data belongs to the withdrawal business type, obtain a virtual resource corresponding to the target withdrawal state data in a contract virtual resource corresponding to the target main chain account as a withdrawal virtual resource.
[0048] The second transfer subunit is further configured to transfer the withdrawal virtual resource out of the resource locking contract.
[0049] The withdrawal change subunit is configured to add the on-chain state data and the target withdrawal state data to obtain state-changed on-chain state data.
[0050] The withdrawal change subunit is further configured to subtract the contract state data and the target withdrawal state data to obtain state-changed contract state data.
[0051] The second transaction business type is a transfer business type, and the state change information includes a target main chain account used for performing the transfer business and target transfer state data; the target main chain account includes a first main chain account and a second main chain account.
[0052] The second change unit comprises:
[0053] The subtraction subunit is configured to, if the transaction data belongs to the transfer business type, subtract the contract state data of the first main chain account and the target transfer state data to obtain state-changed contract state data corresponding to the first main chain account.
[0054] The addition subunit is configured to add the contract state data of the second main chain account and the target transfer state data to obtain state-changed contract state data corresponding to the second main chain account.
[0055] The data processing apparatus further comprises:
[0056] The address creation module is configured to receive a contract address creation request for the target main chain account sent by the business node.
[0057] The address creation module is further configured to create, according to the contract address creation request, a contract address bound to the target main chain account in the resource locking contract as a target contract address; the target contract address is used for storing contract state data of the target main chain account.
[0058] The account creation module is configured to generate an account address creation request to the relay node according to the contract address creation request, so that the relay node creates a subchain account address of a target subchain account bound to a target main chain account in the subchain network according to the account address creation request; and the subchain account address is used to store state data of the target subchain account.
[0059] The embodiment of the present application provides a computer device, including: a processor, a memory, a network interface;
[0060] The processor is connected with the memory and the network interface, wherein the network interface is configured to provide a data communication network element, the memory is configured to store a computer program, and the processor is configured to call the computer program to execute the method in the embodiment of the present application.
[0061] The embodiment of the present application provides a computer readable storage medium, and the computer readable storage medium stores a computer program, and the computer program is suitable for being loaded by a processor and executing the method in the embodiment of the present application.
[0062] The embodiment of the present application provides a computer program product or a computer program, the computer program product or the computer program includes computer instructions, the computer instructions are stored in a computer readable storage medium, a processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method in the embodiment of the present application.
[0063] In the embodiment of the present application, after the relay node of the sub-blockchain network executes the transaction data for the target sub-chain account and obtains the transaction execution result, the total state data of the account in the sub-blockchain network can be obtained, and then the total state data of the account and the to-be-verified total state data of the account are generated according to the transaction execution result and the total state data of the account, and the zero-knowledge proof data is generated according to the total state data of the account and the to-be-verified total state data of the account. Finally, the relay node submits the zero-knowledge proof data and the state change information associated with the transaction execution result to the main-chain node of the main-blockchain network, and when the zero-knowledge proof data is proved and verified, the state data of the target main-chain account can be changed according to the state change information. The total state data of the account includes the state data of at least two sub-chain accounts, and the at least two sub-chain accounts include the target sub-chain account; the target sub-chain account and the target main-chain account are associated. Through the method provided in the embodiment of the present application, the main-chain account in the main-blockchain network is associated with the sub-chain account in the sub-blockchain network, the transaction logic for the target main-chain account is converted into transaction data for the target sub-chain account, and then the transaction data is executed in the relay node of the sub-blockchain network. The main-chain node verifies the zero-knowledge proof data generated after the relay node executes the transaction data, and after the verification is passed, the state data of the main-chain account can be changed according to the state change information, which saves the time for the main-chain node to execute the transaction, greatly improves the TPS of the main-blockchain network, and in addition, the execution data related to the transaction data in the sub-blockchain network does not need to be submitted to the main-blockchain network, which also relieves the transaction storage pressure in the main-blockchain network. BRIEF DESCRIPTION OF DRAWINGS
[0064] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without any creative effort.
[0065] Figure 1 is a network architecture schematic diagram provided by the embodiment of the present application;
[0066] Figures 2a-2b is a scene schematic diagram of data processing based on a block chain provided by the embodiment of the present application;
[0067] Figure 3 is a flow schematic diagram of a data processing method based on a block chain provided by the embodiment of the present application;
[0068] Figure 4 is a flow schematic diagram of another data processing method based on a block chain provided by the embodiment of the present application;
[0069] Figure 5is a scene schematic diagram of a storage transaction processing provided by an embodiment of the present application;
[0070] Figure 6 is a scene schematic diagram of a transaction processing provided by an embodiment of the present application;
[0071] Figure 7 is a scene schematic diagram of a transfer transaction processing provided by an embodiment of the present application;
[0072] Figure 8 is an interaction schematic diagram of a data processing method based on a block chain provided by an embodiment of the present application;
[0073] Figure 9 is a structure schematic diagram of a data processing device based on a block chain provided by an embodiment of the present application;
[0074] Figure 10 is a structure schematic diagram of a computer device provided by an embodiment of the present application;
[0075] Figure 11 is a structure schematic diagram of another data processing device based on a block chain provided by an embodiment of the present application;
[0076] Figure 12 is a structure schematic diagram of another computer device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0077] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor fall within the scope of protection of the present application.
[0078] Please refer to Figure 1 , Figure 1is a network architecture schematic diagram provided by an embodiment of the present application. The blockchain is a new application mode of distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithm and other computer technologies, mainly used for arranging data in chronological order and encrypting into a ledger, so that it cannot be tampered with and forged, and at the same time, data verification, storage and updating can be carried out. The blockchain is essentially a decentralized database, each node in the database stores a same blockchain, and the blockchain network can distinguish the nodes into consensus nodes and business nodes, wherein the consensus nodes are responsible for the consensus of the whole blockchain network. The process of writing transaction data into the ledger in the blockchain network can be: the client sends transaction data to the business node, and then the transaction data is passed between the business nodes in the blockchain network in the form of a baton until the consensus node receives the transaction data, and then the consensus node packs the transaction data into a block, and carries out consensus with other consensus nodes. After the consensus is passed, the block carrying the transaction data is written into the ledger.
[0079] Among them, it can be understood that the block is a data packet carrying transaction data (i.e. transaction business) on the blockchain network, which is a data structure marked with a timestamp and a hash value of a previous block, and the block is verified and determined by the consensus mechanism of the network.
[0080] Among them, it can be understood that the hash value, also known as the information characteristic value or characteristic value, is generated by converting the input data of any length into a password through a hash algorithm and performing fixed output, and the original input data cannot be retrieved by decrypting the hash value, which is a one-way encryption function. In the blockchain, each block (except the initial block) contains the hash value of the previous block, and the previous block is called the parent block of the current block. The hash value is the potential core foundation and the most important aspect in the blockchain technology, which preserves the authenticity of the recorded and viewed data, and the integrity of the blockchain as a whole.
[0081] In the blockchain system, a smart contract can be included, which can be understood as a code understood and executed by each node (including consensus nodes) in the blockchain system, which can execute any logic and obtain a result. A user can call a smart contract already deployed on the blockchain by initiating a transaction service request through a client, and then the service nodes on the blockchain can send the transaction service request to the consensus nodes, and each consensus node on the blockchain can run the smart contract. It should be understood that one or more smart contracts can be included in the blockchain, which can be distinguished by identity document (ID) or name, and the identity number or name of the smart contract can also be carried in the transaction service request initiated by the client to specify the smart contract to be run by the blockchain. If the smart contract specified by the client is a contract that needs to read data, each consensus node will access the local ledger to read data, and finally each consensus node will verify whether the execution results are consistent (i.e., consensus), and if so, the execution results can be stored in the local ledger and returned to the client.
[0082] As shown in Figure 1 , the network architecture can include a main chain node cluster 10, a sub-chain node cluster 100, and a terminal device (client) cluster 1000. The main chain node cluster 10 can include a plurality of main chain nodes, and the sub-chain node cluster can include a plurality of sub-chain nodes. As shown in Figure 1 , the main chain node cluster 10 can include main chain nodes 10a, 10b, 10c, …, 10n, the sub-chain node cluster 100 can specifically include sub-chain nodes 100a, 100b, 100c, …, 100n, and the terminal device cluster 1000 can specifically include terminal devices 1000a, 1000b, …, 1000n.
[0083] The data connection can exist between each main chain node, thereby ensuring data intercommunication between the main chain nodes. For example, the data connection exists between the main chain node 10a and the main chain node 10b, and the data connection exists between the main chain node 10a and the main chain node 10c. Similarly, the data connection can exist between each sub-chain node, thereby ensuring data intercommunication between the sub-chain nodes. For example, the data connection exists between the sub-chain node 100a and the sub-chain node 10b, and the data connection exists between the sub-chain node 10a and the sub-chain node 10c. In addition, each main chain node in the main chain node cluster or each sub-chain node in the sub-chain node cluster can receive the data sent by the terminal device cluster 1000 when normally working, and perform block chaining processing based on the received data. The main chain node cluster 10 can also send data to the terminal device cluster 1000, that is, any main chain node in the main chain node cluster 10 can have a data connection with any sub-chain node in the sub-chain node cluster 100, any main chain node in the main chain node cluster 10 can also have a data connection with any terminal device in the terminal device cluster 1000, and any sub-chain node in the sub-chain node cluster 100 can also have a data connection with any terminal device in the terminal device cluster 1000. For example, the terminal device 1000a, the main chain node 10a, and the sub-chain node 100a all have data connections with each other.
[0084] It can be understood that the data connection is not limited to the connection mode. The data connection can be directly or indirectly connected through a wired communication mode, directly or indirectly connected through a wireless communication mode, or connected through other connection modes, which are not limited in the present application.
[0085] It can be understood that the data processing method provided by the embodiments of the present application can be executed by a computer device, which includes but is not limited to the above-mentioned main chain node (which can be a terminal or a server), sub-chain node (which can be a terminal or a server), and terminal device. The server can be a stand-alone physical server, a server cluster or a distributed system composed of multiple physical servers, a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDNs, and basic cloud computing services such as big data and artificial intelligence platforms. The terminal can be a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited thereto.
[0086] It can be understood that the embodiments of the present application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, intelligent transportation, and assisted driving scenarios.
[0087] For example, Figure 1As shown, the main chain node cluster 10 constitutes a main blockchain network, and each main chain node in the main chain node cluster 10 stores a same main blockchain, and the blocks generated in the main blockchain network are all chained to the main blockchain after consensus. It can be understood that not all participating nodes in the blockchain have sufficient resources and necessity to become consensus nodes of the blockchain, therefore, part of the main chain nodes in the main chain node cluster 10 can participate in the consensus of the blocks as consensus nodes, for example, the main chain node 10a, the main chain node 10c, …, the main chain node 10n are consensus nodes, which perform consensus on the blocks (containing a batch of transactions) of the main blockchain, including generating blocks and voting on the blocks; and the non-consensus nodes do not participate in the consensus, but help to propagate block and voting messages, and synchronize states with each other. Similarly, the sub-chain node cluster 100 constitutes a sub-blockchain network, and each sub-chain node in the sub-chain node cluster 100 stores a same sub-blockchain, and the blocks generated in the sub-blockchain network are all chained to the sub-blockchain after consensus. Only part of the sub-chain nodes in the sub-chain node cluster 100 need to participate in the block consensus of the sub-blockchain as consensus nodes.
[0088] As shown in Figure 1 , the main blockchain in the main blockchain network can include a plurality of main chain accounts, wherein the main chain account can be bound to a user, and corresponds to state data, which includes an account balance, used to represent the virtual resources owned by the user bound to the main chain account in the main blockchain. The virtual resource refers to a digital product that represents the assets (for example, game equipment) owned by the user in reality in a digital form and is secured by encryption technology. In the digital product transaction scenario, the more main chain accounts, the more transactions can be generated in the main blockchain network at the same time. However, the overall performance of the main blockchain network is limited, and at this time the waiting time of the transaction will be too long, and the data generated by the transaction also needs to be stored in the main blockchain network, which is easy to cause the data inflation of the main blockchain network. Therefore, the transactions of the main chain accounts in the main blockchain network can be transferred to the sub-blockchain network for execution, and a batch of transactions are executed in the sub-blockchain network, and the main blockchain network only needs to execute a transaction including the state change information corresponding to the batch of transactions, and the related data of the batch of transactions does not need to be chained to the main blockchain network, but can be stored in the sub-blockchain network, which can solve the problem of insufficient TPS and data storage overload of the main blockchain network in the digital product transaction scenario.
[0089] The specific implementation process of transferring the transactions of the main chain accounts in the main blockchain network to the sub-blockchain network for execution, executing a batch of transactions in the sub-blockchain network, and then executing a transaction including the state change information corresponding to the batch of transactions in the main blockchain network, please refer to Figures 2a-2b , Figures 2a-2bThis is a schematic diagram illustrating a blockchain-based data processing scenario provided in an embodiment of this application. Wherein, as... Figure 2a The main chain node 200 shown can be the one described above. Figure 1 In the corresponding embodiment, any main chain node in the main chain node cluster 10, such as main chain node 200, can be main chain node 10a; for example, Figure 2a The relay node 201 shown can be the one described above. Figure 1 In the corresponding embodiment, any sub-chain node in the sub-chain node cluster 100, such as relay node 201, can be sub-chain node 100a; for example... Figure 2a The terminal devices 202 and 203 shown can be the above-mentioned Figure 1 Any two terminal devices in the terminal device cluster 1000 in the corresponding embodiment, for example, terminal device 202 can be terminal device 1000b, and terminal device 203 can be terminal device 1000a.
[0090] like Figure 2a As shown, main chain node 200 stores total contract state data 204. Total contract state data 204 includes contract state data corresponding to each main chain account in the main blockchain network to which the main chain node belongs. The contract state data package contains contract balances, which represent the virtual resources corresponding to the asset lock-up contracts of the main chain accounts in the main blockchain. From total contract state data 204, it can be seen that the contract balance of main chain account A in the main blockchain network is 100; the contract balance of main chain account B is 50; the contract balance of main chain account C is 80; and the contract balance of main chain account D is 60. In this application, a main chain account in the main blockchain network can be associated with a sub-chain account in a sub-blockchain network. The contract state data corresponding to the virtual resources stored in the asset-locked contract of the main chain account should be consistent with the state data of its associated sub-chain account. For example, if sub-chain account A is associated with main chain account A, then the account balance of sub-chain account A should be 100; if sub-chain account B is associated with main chain account B, then the account balance of sub-chain account B should be 50; if sub-chain account C is associated with main chain account C, then the account balance of sub-chain account C should be 80; and if sub-chain account D is associated with main chain account D, then the account balance of sub-chain account D should be 60. The total account state data 205 stored in relay node 201 can include the state data corresponding to each sub-chain account. Figure 2aAs shown, assuming that the terminal device 202 initiates a transaction 206 of transferring 20 from the main chain account A to the main chain account B to the main chain node 200, and at the same time, the terminal device 203 initiates a transaction 207 of transferring 50 from the main chain account C to the main chain account D to the main chain node 200, after receiving the transaction 206, the main chain node 200 can first simply verify the legality of the transaction 206, for example, whether the contract balance of the main chain account A is greater than 20, etc. If the transaction 206 is verified to be legal, the main chain node 200 can initiate a transaction 208 of transferring 20 from the sub chain account A to the sub chain account B to the relay node 201 according to the transaction 206. Similarly, the main chain node 200 can also initiate a transaction 209 of transferring 50 from the sub chain account C to the sub chain account D to the relay node 202 based on the transaction 207. It can be understood that since the account balance of the sub chain account is consistent with the contract balance of the main chain account, therefore, after the relay node 201 executes the transaction 208 and the transaction 209, the account balance change of the sub chain account should be consistent with the contract balance change of the main chain account after the main chain node 200 executes the transaction 206 and the transaction 207. Therefore, when the main chain node 200 in the main blockchain network receives a transaction for the virtual resource stored in the asset lock contract of the target main chain account, it can be converted into a transaction for the target sub chain account associated with the target main chain account, and then send the transaction for the target sub chain account to the relay node 201, and the sub blockchain network is used to complete the execution and chaining of the transaction. After the relay node 201 executes the transaction, the state change information is generated according to the execution result of the transaction, and the state change information is returned to the main chain node 200. The main chain node 200 does not need to execute the transaction, and directly changes the contract total state data 204 according to the state change information.
[0091] However, in order to ensure the safety and rigor of the data, the main chain node 200 should confirm that the relay node 201 has truly executed the transaction 208 and the transaction 209, and then change the contract total state data 204 according to the state change information. As shown in FIG. 2B, the main chain node 200 can send a query request 210 to the relay node 201 to query the state change information of the target sub chain account. The relay node 201 can receive the query request 210, and return the state change information of the target sub chain account to the main chain node 200 according to the query request 210. Figure 2bAs shown, the relay node 201 can perform the transactions obtained in the target time period in batches, and here only the execution of the transaction 208 and the transaction 209 by the relay node 201 is taken as an example for description, and in fact the relay node 201 can receive multiple transactions sent by multiple main chain nodes in the target time period, and then execute all the transactions. After the relay node 201 executes the transactions, the transaction execution result 210 can be obtained, and according to the transaction execution result 210 and the account total state data 205, the to-be-verified account total state data 211 can be obtained. It should be understood that at this time, in the subchain network, the transaction 208 and the transaction 209 and the corresponding transaction execution result 210 have not been consensus on-chain, so at this time the account total state data 205 in the subchain network has not been actually changed. After the relay node 201 obtains the account total state data 205 and the to-be-verified account total state data 211, zero-knowledge proof generation can be performed based on the account total state data 205 and the to-be-verified account total state data 211, and zero-knowledge proof data for proving that the transaction 208 and the transaction 209 are executed correctly can be obtained. The zero-knowledge proof means that the prover can make the verifier believe that a certain proposition is correct without providing any useful information to the verifier. The relay node 201 can generate zero-knowledge proof data that does not disclose the specific execution process of the transaction, but can prove that the transaction is indeed executed correctly, and the main chain node 200 only needs to verify whether the zero-knowledge proof data passes, so as to determine whether the relay node 201 has successfully executed the batch of transactions. For example, the main chain node 200 can send a request for zero-knowledge proof to the relay node 201, and the relay node 201 can send the zero-knowledge proof data to the main chain node 200. The main chain node 200 can verify the zero-knowledge proof data, and if the zero-knowledge proof data passes, it can be determined that the relay node 201 has successfully executed the batch of transactions. Figure 2bAs shown, the relay node 201 can submit the proof transaction 214 corresponding to the batch of transactions (i.e., the transaction 208 and the transaction 209) to the main chain node 200, where the proof transaction 214 is composed of the zero-knowledge proof data 212 corresponding to the batch of transactions and the state change information 213 corresponding to the batch of transactions. The state change information 213 only needs to include the simplified transaction execution result information corresponding to the transaction execution, for example, the state change information 213 is: the contract balance of the main chain account A is 80, the contract balance of the main chain account B is 70, the contract balance of the main chain account C is 30, and the contract balance of the main chain account D is 110. After receiving the proof transaction 214, the main chain node 200 can call the proof contract to verify the zero-knowledge proof data in the proof transaction 214, and after the verification is passed, the contract total state data 204 can be changed according to the state change information to obtain the changed contract total state data 215. In addition, the relay node can be a block node in the sub-chain network, and the batch of transactions can be packaged into a block, and then the block is sent to the remaining sub-chain consensus nodes in the sub-chain node cluster for consensus. After the consensus is passed, the batch of transactions and the corresponding transaction execution result are written into the ledger of the sub-chain network, and at this time, the total state data 205 of the sub-chain network is changed to the to-be-verified total state data 211 of the account. It can be understood that the account balance of the changed sub-chain account is consistent with the contract balance of the changed main chain account.
[0092] It can be understood that in the specific embodiments of the present application, the transaction data, state data and other related data involved in the above embodiments of the present application need to obtain user permission or consent when applied to specific products or technologies, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0093] Through the data processing method provided by the embodiments of the present application, the plurality of transactions in the main blockchain network can be executed in the sub-chain network. The main blockchain network only needs to perform consensus and chain of the proof transaction containing the zero-knowledge proof data and the state change information corresponding to the plurality of transactions, which greatly improves the TPS of the main blockchain and relieves the storage pressure of the main blockchain.
[0094] Further, please refer to Figure 3 , Figure 3 is a flow diagram of a data processing method based on a blockchain provided by an embodiment of the present application. The method can be executed by a relay node (for example, any sub-chain node in the sub-chain node cluster 100 in the above-mentioned Figure 1 corresponding embodiment). The following will be described by taking the execution of the method by the relay node as an example, where the data processing method based on a blockchain at least can include the following steps S101-S104:
[0095] In step S101, the relay node executes transaction data for the target subchain account to obtain a transaction execution result; the relay node belongs to the subchain network.
[0096] Specifically, the relay node can receive transaction data for the target subchain account from the main chain node, or directly receive transaction data for the target subchain account from the terminal device. The relay node can execute the transaction data in batches, that is, package multiple pieces of transaction data received in a target time period into a to-be-chained block. The relay node executes the batch of transaction data to obtain a transaction execution result.
[0097] In step S102, total account state data in the subchain network is obtained, and based on the transaction execution result and the total account state data, to-be-verified total account state data is generated; the total account state data includes state data of at least two subchain accounts, and the at least two subchain accounts include the target subchain account.
[0098] Specifically, the state data of a subchain account refers to data of the subchain account stored in the subchain, and the state data includes an account balance, which is used to represent virtual resources possessed by the subchain account in the subchain network. The state data of all subchain accounts in the subchain network constitutes total account state data in the subchain network. When transaction data for the target subchain account is executed in the subchain network, the state data of the target subchain account needs to be prepared for change, and accordingly, the total account state data in the subchain network also needs to be prepared for change. For example, the account balance of subchain account a is 100, the account balance of subchain account b is 50, transaction 1 is a transfer of 20 from subchain account a to subchain account b, after transaction 1 is executed, the account balance of subchain account a needs to be changed to 80, and the account balance of subchain account b needs to be changed to 70.
[0099] Specifically, the sub-chain blockchain network can store virtual resources of different resource types, at this time, the different resource types of virtual resources owned by the sub-chain account need to be represented by different balances, for example, the state data of the sub-chain account c is "tokenX: 100, tokenY: 80", wherein tokenX is used to represent virtual resource X of resource type X, and tokenY is used to represent virtual resource Y of resource type Y, that is, at this time, the sub-chain account c owns 100 virtual resources X and 80 virtual resources Y. In addition, different virtual resources cannot be superimposed, and different sub-chain accounts can trade virtual resources of the same resource type. Assuming that the state data of the sub-chain account d is "tokenX: 100, tokenY: 80", and transaction 2 is that the sub-chain account c transfers 50 virtual resources X to the sub-chain account d, then after the execution of transaction 2 is completed, the state data of the sub-chain account c needs to be changed to "tokenX: 50, tokenY: 80", and the state data of the sub-chain account d needs to be changed to "tokenX: 150, tokenY: 80".
[0100] Specifically, according to the transaction execution result and the account total state data, the to-be-verified account total state data can be obtained. It should be understood that before the transaction execution result is written into the ledger of the sub-chain blockchain network, the account total state data in the sub-chain blockchain network will not change, that is, after the transaction data is executed, the account total state data needs to be changed to the to-be-verified account total state data, and when the subsequent transaction execution result is written into the ledger of the sub-chain blockchain network, the account total state data can be truly changed to the to-be-verified account total state data.
[0101] In step S103, zero-knowledge proof data is generated according to the account total state data and the to-be-verified account total state data.
[0102] Specifically, in the embodiment of the present application, the transaction data of the virtual resource stored in the asset lock contract for the target main chain account is converted into transaction data for the target sub-chain account having an association relationship with the target main chain account, and the transaction data is executed by the sub-chain blockchain network, thereby reducing the task amount of transaction execution in the main chain blockchain network. The relay node can generate zero-knowledge proof data according to the account total state data and the to-be-verified account total state data to prove that the transaction has indeed been successfully executed. Wherein, the zero-knowledge proof means that the prover proves to the verifier that he knows or owns a certain message, but the proof process cannot leak any information about the proved message to the verifier, that is, the relay node can prove to the main chain node through the zero-knowledge proof data that it has indeed successfully executed the transaction, but does not leak the relevant information in the transaction execution process.
[0103] Specifically, according to the account total state data and the to-be-verified account total state data, a feasible process of generating the zero-knowledge proof data is as follows: performing hash processing on the account total state data to obtain a first state hash value; performing hash processing on the to-be-verified account total state data to obtain a second state hash value; determining state data change values corresponding to the at least two sub-chain accounts according to the account total state data and the to-be-verified account total state data; and then inputting the first state hash value, the second state hash value, and the state data change values into a zero-knowledge proof circuit to obtain the zero-knowledge proof data. The zero-knowledge proof circuit is a circuit designed and compiled based on a calculation process to be proved, and the relay node only needs to provide the input of the zero-knowledge proof circuit, and can calculate the zero-knowledge proof data corresponding to the input according to the zero-knowledge proof circuit. In this application, the first state hash value, the second state hash value, and the state data change value representing the change process of the account total state data in the sub-blockchain network along with the execution result of the transaction are input into the zero-knowledge proof circuit, and the zero-knowledge proof data proving that the relay node indeed successfully executes the transaction can be obtained. Of course, other input zero-knowledge proof circuits can also be used to prove that the relay node indeed successfully executes the transaction, and the embodiments of this application are not limited in this regard.
[0104] Specifically, a feasible process of performing hash processing on the account total state data to obtain the first state hash value is as follows: performing hash operation on the state data of the at least two sub-chain accounts in the account total state data respectively to obtain account state hash values corresponding to the at least two sub-chain accounts respectively; performing hash operation on the account state hash values corresponding to the at least two sub-chain accounts respectively according to the state Merkle tree path to obtain a root hash value, and determining the root hash value as the first state hash value. In addition, the same hash processing can be performed on the to-be-verified account total state data to obtain the second state hash value.
[0105] Step S104: submitting the zero-knowledge proof data and the state change information associated with the transaction execution result to a main chain node, so that the main chain node changes the state data of a target main chain account according to the state change information when the zero-knowledge proof data is proved to be verified; the target sub-chain account and the target main chain account are associated; and the main chain node belongs to a main blockchain network.
[0106] Specifically, according to the account total state data and the to-be-verified account total state data, a feasible process of generating the zero-knowledge proof data is as follows: performing hash processing on the account total state data to obtain a first state hash value; performing hash processing on the to-be-verified account total state data to obtain a second state hash value; determining state data change values corresponding to the at least two sub-chain accounts according to the account total state data and the to-be-verified account total state data; and then inputting the first state hash value, the second state hash value, and the state data change values into a zero-knowledge proof circuit to obtain the zero-knowledge proof data. The zero-knowledge proof circuit is a circuit designed and compiled based on a calculation process to be proved, and the relay node only needs to provide the input of the zero-knowledge proof circuit, and can calculate the zero-knowledge proof data corresponding to the input according to the zero-knowledge proof circuit. In this application, the first state hash value, the second state hash value, and the state data change value representing the change process of the account total state data in the sub-blockchain network along with the execution result of the transaction are input into the zero-knowledge proof circuit, and the zero-knowledge proof data proving that the relay node indeed successfully executes the transaction can be obtained. Of course, other input zero-knowledge proof circuits can also be used to prove that the relay node indeed successfully executes the transaction, and the embodiments of this application are not limited in this regard. Figure 2a and Figure 2bAccording to the corresponding embodiments, the sub-chain accounts in the sub-blockchain network are all associated with the main-chain accounts in the main-blockchain network, when the state data of the sub-chain accounts is consistent with the state data corresponding to the virtual resources stored in the asset locking contract of the main-chain accounts, after the relay node executes the batch of transaction data to obtain the transaction execution result, the state change of the target sub-chain account can be obtained, so that the state change information of the target main-chain account can be obtained, and the state change information is used to instruct the main-chain node to change the state data corresponding to the virtual resources stored in the asset locking contract of the target main-chain account. For example, the state change information can be "target main-chain account, tokenX: 50", and according to the state change information, the main-chain node can change the balance corresponding to the virtual resource X in the state data corresponding to the virtual resources stored in the asset locking contract of the target main-chain account to 50.
[0107] Specifically, the relay node can assemble the zero-knowledge proof data and the state change information into a transaction, and then submit the transaction to the main-chain node in the main-blockchain network. After the main-chain node consensus passes the transaction, the zero-knowledge proof data can be verified, and if the verification is passed, the state change information is used to change the state data corresponding to the virtual resources stored in the asset locking contract of the target main-chain account.
[0108] Optionally, after the main-chain node proves that the zero-knowledge proof data is verified, the relay node can perform consensus processing on the to-be-chained sub-chain block containing the transaction data. When the to-be-chained sub-chain block consensus processing passes, the relay node can write the transaction execution result corresponding to the transaction data into the ledger of the sub-blockchain network, and at this time, the total state data of the accounts in the ledger of the sub-blockchain network will be updated to the to-be-verified total state data of the accounts.
[0109] With the method provided in the embodiments of the present application, the transaction data corresponding to the virtual resources stored in the asset locking contract for the target main chain account in the main blockchain network is converted into transaction data for the target sub chain account associated with the target main chain account in the sub blockchain network. After the relay node in the sub blockchain network executes the transaction data for the target sub chain account to obtain a transaction execution result, the total account state data can be obtained, and the to-be-verified total account state data is generated according to the transaction execution result and the total account state data. Then, the zero-knowledge proof data is generated according to the total account state data and the to-be-verified total account state data, wherein the zero-knowledge proof data is used to prove that the transaction data has indeed been executed. Finally, the relay node submits the zero-knowledge proof data and the state change information to the main chain node. After the main chain node verifies that the zero-knowledge proof data is correct, the state data of the target main chain account can be changed according to the state change information. The main chain node does not need to execute a large amount of transaction data for the virtual resources stored in the asset locking contract, nor does it need to store the related data generated in the execution process, which can improve the TPS of the main blockchain network and relieve the data storage pressure of the main blockchain network.
[0110] Further, please refer to Figure 4 , Figure 4 is a flow diagram of another blockchain-based data processing method provided in the embodiments of the present application. The method can be executed by a main chain node (for example, any main chain node in the main chain node cluster 10 in the above-mentioned Figure 1 corresponding embodiment). The following will be described by taking the execution of the method by the main chain node as an example. The blockchain-based data processing method can at least include the following steps S201-S203:
[0111] In step S201, the main chain node receives the zero-knowledge proof data submitted by the relay node and the state change information associated with the transaction execution result. The main chain node belongs to the main blockchain network, and the relay node belongs to the sub blockchain network.
[0112] Specifically, the zero-knowledge proof data is generated by the relay node according to the total account state data and the to-be-verified total account state data of the sub blockchain network, wherein the to-be-verified total account state data is generated according to the transaction execution result and the total account state data, and the transaction execution result is obtained by the relay node executing the transaction data for the target sub chain account. In addition, the target sub chain account is associated with the target main chain account. The specific generation process can be referred to step S103 in the above-mentioned Figure 3 corresponding embodiment.
[0113] In step 202, the proof contract is called to prove and verify the zero-knowledge proof data, and a proof verification result is obtained.
[0114] Specifically, it is proved that the contract is determined based on the zero-knowledge proof circuit generating the zero-knowledge proof data. The ZoKrates (a tool project) tool can be used to export the proof contract corresponding to the zero-knowledge proof circuit, and the developer can also compile the zero-knowledge proof circuit through the ZoKrates tool. The proof contract is deployed in the main blockchain network, and the main chain node can call the proof contract to verify the zero-knowledge proof data, and then output the proof verification result.
[0115] In step S203, if the proof verification result is a proof verification pass result, the state data of the target main chain account is changed according to the state change information.
[0116] Specifically, in the embodiment of the present application, the virtual resources of the target main chain account can be divided into on-chain virtual resources and contract virtual resources. The on-chain virtual resources refer to the virtual resources owned by the target main chain account in the main blockchain network and not locked in the resource locking contract. The contract virtual resources refer to the virtual resources owned by the target main chain account in the main blockchain network and locked in the resource locking contract. In the main blockchain network, the state data of the target main chain account can include on-chain state data and contract state data. The on-chain state data is used to represent the on-chain virtual resources owned by the target main chain account, and the contract state data is used to represent the contract virtual resources owned by the target main chain account. In this way, the virtual resources owned by the sub-chain account associated with the target main chain account in the sub-blockchain network only need to be consistent with the contract virtual resources of the target main chain account, that is, the total state data of the accounts in the sub-blockchain network only needs to be consistent with the contract state data of the target main chain account. That is, in the main blockchain network, the contract virtual resources stored in the resource locking contract will be locked, and the related transaction data of the contract virtual resources of the target main chain account will be converted into the related transaction data of the target sub-chain account, and the execution process of the transaction data will be executed in the sub-blockchain network. At the same time, the transaction data of the unlocked on-chain virtual resources of the target main chain account can be packaged into a block by the main chain node with block generation authority in the main blockchain network, and then consensus on-chain.
[0117] Specifically, when the state data of the target main chain account includes the on-chain state data and the contract state data, i.e., the contract total state data corresponding to the contract virtual resource in the resource locking contract in the main blockchain network is consistent with the account total state data in the sub-blockchain network, the feasible implementation process of changing the state data of the target main chain account according to the state change information is as follows: if the transaction data belongs to the first transaction business type, the on-chain state data and the contract state data of the target main chain account are changed according to the state change information; if the transaction data belongs to the second transaction business type, the contract state data of the target main chain account is changed according to the state change information. The transaction data of the first transaction business type refers to the transaction data involving the interaction of the on-chain virtual resource and the contract virtual resource of the main chain account, which is used to store the first target amount of on-chain virtual resource into the resource locking contract, or extract the second target amount of contract virtual resource from the resource locking contract to the ledger in the main blockchain network. The target amount of on-chain virtual resource stored in the resource locking contract will also be used as the contract virtual resource, and the contract virtual resource can be considered as the virtual resource stored from the main blockchain network to the sub-blockchain network, because the amount of the virtual resource in the sub-blockchain network will be the same as the amount of the contract virtual resource. The transaction data of the second transaction business type refers to the transaction data only for the contract virtual resource, at this time, the total amount of the contract virtual resource owned by all main chain accounts does not change, and the total amount of the virtual resource in the sub-blockchain network also does not change.
[0118] Specifically, when the first transaction business type is a storage business type, the state change information can include a target main chain account for performing the storage business and target storage state data. If the transaction data belongs to the first transaction business type, according to the state change information, the on-chain state data and the contract state data of the target main chain account are changed, including: if the transaction data belongs to the storage business type, in the on-chain virtual resource corresponding to the target main chain account, a virtual resource corresponding to the target storage state data is obtained as a storage virtual resource; the storage virtual resource is transferred to the resource locking contract for locking; the on-chain state data is subtracted from the target storage state data to obtain the on-chain state data after the state change; and the contract state data is added to the target storage state data to obtain the contract state data after the state change. For example, assuming that the main chain account e is included in the main blockchain network, the on-chain state data of the main chain account e is "tokenX:20, tokenY:50", the contract state data of the main chain account e is "tokenX:50, tokenY:30", and the state change information is "main chain account e, store tokenX:20", the main chain node will store the on-chain virtual resource X in the amount of 20 into the resource locking contract, at this time, the amount of the contract virtual resource X stored in the resource locking contract is 70, the on-chain state data of the main chain account e will be changed to "tokenX:0, tokenY:50", and the contract state data of the main chain account e will be changed to "tokenX:70, tokenY:30".
[0119] For better understanding of the processing process of the transaction of the storage business type, please see Figure 5 , Figure 5 is a scenario diagram of a storage transaction processing provided by an embodiment of the present application. As shown in Figure 5 , the terminal device can be any terminal device in the terminal device cluster 1000 in the embodiments corresponding to the above Figure 1 , such as the terminal device 1000b; as shown in Figure 5 , the main chain node cluster 50 can be the main chain node cluster 10 in the embodiments corresponding to the above Figure 1 ; as shown in Figure 5 , the relay node 51 can be any sub-chain node in the sub-chain node cluster 100 in the embodiments corresponding to the above Figure 1 , such as the sub-chain node 100a.
[0120] As shown in Figure 5 , a user can submit a storage transaction to the main chain through a bound terminal device, for example, the terminal device sends a storage transaction 501 to the main chain node 50a, and the transaction content of the storage transaction 501 is "account A virtual resource X storage 10", that is, user A wants to transfer the virtual resource X on the main chain to the
[0121] The resource is stored in a locked contract for off-chain transactions. At this point, 10 units of virtual resource X are in a pending locked state. The main chain can then send a main chain user storage transaction request to the relay node. For example, main chain node 50a can send storage transaction request 502 to relay node 51. After receiving storage transaction request 502, relay node 502 can collect and package all transaction requests within the target time period on the main chain. For example, block 503 contains storage transaction request 502. Simultaneously, relay node 51 can input block 503 into zero-knowledge proof circuit 52 to generate zero-knowledge proof data 504. Specifically, block 503 contains the transaction execution result corresponding to the transaction request. Relay node 503 can obtain the state data of the sub-chain account, generate the first state hash value 505, and then obtain the unverified state data of the sub-chain account based on the transaction execution result, generating the second state hash value 506. Relay node 503 can also determine the state data change value, that is, the change value of virtual resource X of sub-chain account A. Inputting the first state hash value 505, the second state hash value 506, and the state data change value into zero-knowledge proof circuit 52 can verify the correctness of the state transition process of all transactions in block 503. If the input information conforms to the verification process of zero-knowledge proof circuit, zero-knowledge circuit can output zero-knowledge proof data 504 to prove that the storage transaction request 502 was indeed executed. Subsequently, relay node 51 can generate a proof transaction 507 containing zero-knowledge proof data 504 and state change information to the main chain. Assuming relay node 51 submits proof transaction 507 to main chain node 50b, main chain node 50b can then initiate a consensus process on the main chain for proof transaction 507. If the consensus for proof transaction 507 passes, main chain node 50b will invoke the proof contract to verify the zero-knowledge proof data 504. After successful verification, it will update the on-chain account state and contract account state based on the state change information. Figure 5 As shown, the total contract state data 508 stored in the resource locking contract in the main chain will be changed to the total contract state data 509, and the contract state data 510 of the main chain account A in the main chain will be changed to the contract state data 511. At this time, 10 virtual resources X will be stored in the resource locking contract. At the same time, block 503 will be uploaded to the logical sub-chain 512.
[0122] Specifically, when the first transaction business type is the withdrawal business type, the state change information can include a target main chain account for performing the withdrawal business and target withdrawal state data; if the transaction data belongs to the first transaction business type, the on-chain state data and the contract state data of the target main chain account are changed according to the state change information, including: if the transaction data belongs to the withdrawal business type, in the contract virtual resource corresponding to the target main chain account, a virtual resource corresponding to the target withdrawal state data is obtained as a withdrawal virtual resource; the withdrawal virtual resource is transferred out of the resource locking contract; the on-chain state data and the target withdrawal state data are added to obtain the on-chain state data after the state change; the contract state data and the target withdrawal state data are subtracted to obtain the contract state data after the state change. For example, assuming that the main blockchain network includes a main chain account f, the on-chain state data of the main chain account f is "tokenX:20, tokenY:50", the contract state data of the main chain account f is "tokenX:50, tokenY:30", and the state change information is "main chain account f, withdraw tokenX:20", the main chain node will withdraw 20 contract virtual resources X from the resource locking contract to store outside the resource locking contract, at this time, the number of contract virtual resources X stored in the resource locking contract is 30, the on-chain state data of the main chain account f will be changed to "tokenX:40, tokenY:50", and the contract state data of the main chain account f will be changed to "tokenX:30, tokenY:30".
[0123] For better understanding of the transaction processing process of the withdrawal business type, please see Figure 6 , Figure 6 is a scene diagram of a withdrawal transaction processing provided by an embodiment of the present application. As shown in Figure 6 , the terminal device can be any terminal device in the terminal device cluster 1000 in the embodiment corresponding to Figure 1 , such as terminal device 1000b; as shown in Figure 6 , the main chain node cluster 60 can be the main chain node cluster 10 in the embodiment corresponding to Figure 1 ; as shown in Figure 6 , the relay node 61 can be any sub-chain node in the sub-chain node cluster 100 in the embodiment corresponding to Figure 1 , such as the sub-chain node 100a.
[0124] As shown in Figure 6As shown, the user can submit a withdrawal transaction to the main chain through the bound terminal device, for example, the terminal device sends a withdrawal transaction 601 to the main chain node 60a, and the transaction content of the storage transaction 601 is "account A virtual resource Y withdrawal 10", that is, user A wants to transfer the virtual resource Y in the quantity of 10 in the asset lock contract to the chain for transaction in the main blockchain network. At this time, the virtual resource Y in the quantity of 10 will be in a state of waiting for locking. Then the main chain can send a main chain user withdrawal transaction request to the relay, for example, the main chain node 60a can send a storage transaction request 602 to the relay node 61, and the relay node 602 can collect and package all the transaction requests in the target time period on the main chain after receiving the withdrawal transaction request 602, for example, the block 603 contains the withdrawal transaction request 602. At the same time, the relay node 61 can input the block 603 into the zero-knowledge proof circuit 62 to generate zero-knowledge proof data 604. Specifically, the block 603 contains the transaction execution result corresponding to the transaction request, the relay node 603 can obtain the state data of the subchain account, generate a first state hash value 605, and then obtain the to-be-verified state data of the subchain account according to the transaction execution result, generate a second state hash value 606, and the relay node 603 can also determine the state data change value, that is, the change value of the virtual resource Y of the subchain account A, and input the first state hash value 605, the second state hash value 606 and the state data change value into the zero-knowledge proof circuit 62, which can verify the correctness of the state transition process of all transactions in the block 603. If the input information conforms to the verification process of the zero-knowledge proof circuit, the zero-knowledge circuit can output the zero-knowledge proof data 604 for proving that the withdrawal transaction request 602 is indeed executed. Subsequently, the relay node 61 can generate a proof transaction 607 containing the zero-knowledge proof data 604 and the state change information to the main chain, assuming that the relay node 61 submits the proof transaction 607 to the main chain node 60b, and then the main chain node 60b can initiate consensus on the chain for the proof transaction 607 in the main chain. If the proof transaction 607 is consensus, the main chain node 60b will call the proof contract to verify the zero-knowledge proof data 604, and after the verification is passed, the chain account state and the contract account state are changed according to the state change information. As Figure 6 As shown, the total contract state data 608 stored in the resource lock contract in the main chain will be changed to the total contract state data 609, and the contract state data 610 of the main chain account A in the main chain will be changed to the contract state data 611. At this time, the virtual resource X in the quantity of 10 will be transferred from the resource lock contract to the chain. At the same time, the block 603 will be chained to the logical subchain 612.
[0125] Specifically, when the second transaction type is a transfer type, the state change information can include a target main chain account for performing the transfer transaction and target transfer state data, where the target main chain account includes the first main chain account and the second main chain account. If the transaction data belongs to the second transaction type, the contract state data of the target main chain account is changed according to the state change information, including: if the transaction data belongs to the transfer type, the contract state data of the first main chain account is subtracted from the target transfer state data to obtain the state changed contract state data corresponding to the first main chain account; and the contract state data of the second main chain account is added to the target transfer state data to obtain the state changed contract state data corresponding to the second main chain account. Assuming that the main blockchain network includes a main chain account g and a main chain account h, the contract state data of the main chain account g is "tokenX:60, tokenY:30", the contract state data of the main chain account h is "tokenX:40, tokenY:90", and the state change information is "main chain account g transfers tokenY:20 to main chain account h", the contract state data of the main chain account g is changed to "tokenX:60, tokenY:10", and the contract state data of the main chain account h is changed to "tokenX:40, tokenY:110".
[0126] For better understanding of the processing process of the transaction of the transfer type, please see Figure 7 , Figure 7 is a scene diagram of a transfer transaction provided by an embodiment of the present application. As shown in Figure 7 , the terminal device can be any terminal device in the terminal device cluster 1000 in the embodiment corresponding to Figure 1 , such as terminal device 1000b. As shown in Figure 7 , the main chain node cluster 70 can be the main chain node cluster 10 in the embodiment corresponding to Figure 1 , and as shown in Figure 7 , the relay node 71 can be any sub-chain node in the sub-chain node cluster 100 in the embodiment corresponding to Figure 1 , such as sub-chain node 100a.
[0127] As shown in Figure 7As shown, the user can send a transfer transaction request 701 to the relay node 72 through the bound terminal device, and the transaction content of the transfer transaction request 701 can be "account B virtual resource X is transferred to account A by 10", and the main chain node 70a can send a transfer transaction request 702 to the relay node 71, and the transaction content of the transfer transaction request 702 can be "account A virtual resource Y is transferred to account B by 10", and the transfer transaction request 702 can be generated by the main chain node 70a based on the received transfer transaction. The relay can collect and package all transaction requests in the target time period on the main chain, for example, the block 703 contains the transfer transaction request 701 and the transfer transaction request 702. At the same time, the relay node 71 can input the block 703 into the zero-knowledge proof circuit 72 to generate zero-knowledge proof data 704. Specifically, the block 703 contains the transaction execution result corresponding to the transaction request, the relay node 703 can obtain the state data of the subchain account, generate a first state hash value 705, then obtain the to-be-verified state data of the subchain account according to the transaction execution result, generate a second state hash value 706, and the relay node 703 can also determine the state data change value, that is, the change value of each virtual resource in the subchain account. The first state hash value 705, the second state hash value 706 and the state data change value are input into the zero-knowledge proof circuit 72, and the correctness of the state transition process of all transactions in the block 703 can be verified. If the input information conforms to the verification process of the zero-knowledge proof circuit, the zero-knowledge circuit can output the zero-knowledge proof data 704, which is used to prove that the extraction transaction request 702 is indeed executed. Subsequently, the relay node 71 can generate a proof transaction 707 containing the zero-knowledge proof data 704 and the state change information to the main chain. It is assumed that the relay node 71 submits the proof transaction 707 to the main chain node 70b, and then the main chain node 70b can initiate consensus on the main chain for the proof transaction 707. If the proof transaction 707 is consensus, the main chain node 70b will call the proof contract to verify the zero-knowledge proof data 704, and after the verification is passed, the contract account state is changed according to the state change information. As shown, the total contract state data 708 stored in the resource lock contract in the main chain is changed to the total contract state data 709. Figure 7 As shown, the main chain node 70a can send a transfer transaction request 702 to the relay node 71, and the transaction content of the transfer transaction request 702 can be "account A virtual resource Y is transferred to account B by 10", and the transfer transaction request 702 can be generated by the main chain node 70a based on the received transfer transaction. The relay can collect and package all transaction requests in the target time period on the main chain, for example, the block 703 contains the transfer transaction request 701 and the transfer transaction request 702. At the same time, the relay node 71 can input the block 703 into the zero-knowledge proof circuit 72 to generate zero-knowledge proof data 704. Specifically, the block 703 contains the transaction execution result corresponding to the transaction request, the relay node 703 can obtain the state data of the subchain account, generate a first state hash value 705, then obtain the to-be-verified state data of the subchain account according to the transaction execution result, generate a second state hash value 706, and the relay node 703 can also determine the state data change value, that is, the change value of each virtual resource in the subchain account. The first state hash value 705, the second state hash value 706 and the state data change value are input into the zero-knowledge proof circuit 72, and the correctness of the state transition process of all transactions in the block 703 can be verified. If the input information conforms to the verification process of the zero-knowledge proof circuit, the zero-knowledge circuit can output the zero-knowledge proof data 704, which is used to prove that the extraction transaction request 702 is indeed executed. Subsequently, the relay node 71 can generate a proof transaction 707 containing the zero-knowledge proof data 704 and the state change information to the main chain. It is assumed that the relay node 71 submits the proof transaction 707 to the main chain node 70b, and then the main chain node 70b can initiate consensus on the main chain for the proof transaction 707. If the proof transaction 707 is consensus, the main chain node 70b will call the proof contract to verify the zero-knowledge proof data 704, and after the verification is passed, the contract account state is changed according to the state change information. As shown, the total contract state data 708 stored in the resource lock contract in the main chain is changed to the total contract state data 709.
[0128] Optionally, the main chain node can receive a contract address creation request for the target main chain account sent by the service node, and the main chain node can create a contract address bound to the target main chain account in the resource lock contract according to the contract address creation request, as the target contract address. The target contract address is used to store the contract state data of the target main chain account. At the same time, the main chain node can generate an account address creation request to the relay node according to the contract address creation request, and the relay node can create a subchain account address bound to the target subchain account associated with the target main chain account in the subchain network according to the account address creation request. The subchain account address is used to store the state data of the target subchain account.
[0129] By adopting the method provided in the embodiments of the present application, the virtual resources in the main blockchain network can be transferred to the resource lock contract for storage, the virtual resources stored in the resource lock contract will be used as contract virtual resources, the execution process of the transaction data related to the contract virtual resources in the main blockchain network is transferred to the subchain network for execution to obtain a transaction execution result, the main chain node only needs to receive the zero-knowledge proof data submitted by the relay node and the state change information associated with the transaction execution result, and then call the proof contract to perform proof verification on the zero-knowledge proof data to obtain a proof verification result. If the proof verification result is a proof verification pass result, the state data of the target main chain account can be changed according to the state change information, which saves the time for the main chain node to execute the transaction, greatly improves the TPS of the main blockchain network, and the execution data related to the transaction data in the subchain network does not need to be submitted to the main blockchain network, which also relieves the transaction storage pressure in the main blockchain network. In addition, the on-chain virtual resources in the main blockchain network that are not stored in the resource lock contract can be normally traded, which greatly improves the flexibility of the main blockchain network for virtual resource transactions and speeds up the transaction processing speed.
[0130] Further, please refer to Figure 8 , Figure 8 is an interaction schematic diagram of a data processing method based on a blockchain provided by an embodiment of the present application. The data processing method is suitable for a virtual resource transaction scenario, such as Figure 8As shown, the entire data interaction process is based on three services, namely, an off-chain relay (Operator) service, an off-chain circuit (Circuit) service, and a main chain (Ethereum) service. Among them, the off-chain relay service of the Operator mainly collects on-chain and off-chain transactions of users, and executes the collected transactions off-chain and packs to generate block_data (block data) data. Among them, the off-chain circuit service of the Circuit mainly runs the block_data data packed by the off-chain relay service in the circuit to generate the proof (proof) of off-chain calculation, that is, zero-knowledge proof data, and forms a transaction with the proof and submits it to the main chain. Among them, the main chain service receives the proof transaction submitted by the operator, and verifies the transaction in the contract of the main chain, that is, the off-chain execution of a batch of transactions can be completed, and the on-chain only needs to verify the proof of a batch of transactions generated off-chain to complete the state change of a batch of transactions. Among them, the off-chain relay service and the off-chain circuit service can be implemented by the relay nodes in the sub-blockchain network described above, and the main chain service can be implemented by the main chain nodes in the main blockchain network described above.
[0131] As shown in Figure 8 , the flow of the entire data interaction process is as follows:
[0132] ①, the user can initiate an on-chain transaction to the on-chain node (which can be the main chain node in the main blockchain network described above) providing the main chain service through the bound terminal device. The on-chain node can convert it into an off-chain transaction and send it to the off-chain node (which can be the sub-chain node in the sub-blockchain network described above) providing the off-chain relay service.
[0133] ②, the user can also send an off-chain transaction directly to the off-chain node providing the off-chain relay service through the bound terminal device.
[0134] ③, the off-chain node providing the off-chain relay service executes the collected transactions and packs the transactions to generate a block data.
[0135] ④, the off-chain node providing the off-chain relay service calculates the state change (which can be the total state data of the account in the sub-blockchain network described above and the total state data to be verified) of the off-chain account (which can be the sub-chain account in the sub-blockchain network described above) before and after the transaction based on the block data, and generates state information (which can be the first state hash value, the second state hash value, and the state data change value).
[0136] V, the off-chain node providing the off-chain relay service inputs the state information to the off-chain node providing the off-chain circuit service, the off-chain node providing the off-chain circuit service inputs the state information to the circuit, and zero-knowledge proof data proof can be obtained and returned to the off-chain node providing the off-chain relay service. It can be understood that the off-chain node providing the off-chain relay service and the off-chain node providing the off-chain circuit service can be the same node.
[0137] VI, the off-chain node providing the off-chain relay service assembles the proof and the state change information into a transaction and submits the transaction to the on-chain node providing the main chain service, and the on-chain node providing the main chain service performs consensus on the transaction in the contract of the main chain.
[0138] By using the method provided in the embodiments of the present application, the off-chain relay service, the off-chain circuit service and the main chain service are introduced in the virtual resource transaction scenario, the transactions in the main blockchain network are transferred to the off-chain for execution, and the transactions can be executed in batches, only the zero-knowledge proof data of correct execution of the batch of transactions needs to be generated off-chain, the state change information associated with the transaction execution result is assembled into a proof transaction and submitted to the on-chain, and the on-chain only needs to perform consensus on the proof transaction. As long as it is determined that the zero-knowledge proof data in the proof transaction is passed, it is considered that the batch of transactions executed by the sub-chain are all valid, which can greatly improve the TPS of the virtual resource transaction and relieve the data storage pressure on the main chain, and improve the transaction experience of the virtual resource in the main blockchain network.
[0139] Please refer to Figure 9 , Figure 9 is a structural schematic diagram of a data processing device based on a blockchain provided by an embodiment of the present application. The data processing device can be a computer program (including program code) running on a computer device, for example, the data processing device is an application software; the device can be used to execute the corresponding steps in the data processing method provided by the embodiments of the present application. As shown in Figure 9 , the data processing device 1 can include an execution module 11, a state generation module 12, a proof generation module 13 and a submission module 14.
[0140] The execution module 11 is configured to execute transaction data for a target sub-chain account to obtain a transaction execution result; the relay node belongs to a sub-blockchain network;
[0141] The state generation module 12 is configured to obtain total account state data in the sub-blockchain network, and generate to-be-verified total account state data according to the transaction execution result and the total account state data; the total account state data includes state data of at least two sub-chain accounts, and the at least two sub-chain accounts include the target sub-chain account;
[0142] The proof generation module 13 is configured to generate zero-knowledge proof data according to the total account state data and the to-be-verified total account state data.
[0143] The submission module 14 is configured to submit the zero-knowledge proof data and the state change information associated with the transaction execution result to a main chain node, so that the main chain node changes the state data of a target main chain account according to the state change information when the zero-knowledge proof data is proved to be verified; the target subchain account is associated with the target main chain account; and the main chain node belongs to a main blockchain network.
[0144] The specific implementation manners of the execution module 11, the state generation module 12, the proof generation module 13, and the submission module 14 can be referred to the descriptions of the steps S101-S104 in the above Figure 3 corresponding embodiments, and thus will not be described here in detail.
[0145] Please refer to Figure 9 The proof generation module 13 comprises a first hash unit 131, a second hash unit 132, a change determination unit 133, and a proof generation unit 134.
[0146] The first hash unit 131 is configured to perform hash processing on the total account state data to obtain a first state hash value.
[0147] The second hash unit 132 is configured to perform hash processing on the to-be-verified total account state data to obtain a second state hash value.
[0148] The change determination unit 133 is configured to determine state data change values respectively corresponding to the at least two subchain accounts according to the total account state data and the to-be-verified total account state data.
[0149] The proof generation unit 134 is configured to input the first state hash value, the second state hash value, and the state data change values into a zero-knowledge proof circuit to obtain the zero-knowledge proof data.
[0150] The specific implementation manners of the first hash unit 131, the second hash unit 132, the change determination unit 133, and the proof generation unit 134 can be referred to the description of the step S103 in the above Figure 3 corresponding embodiments, and thus will not be described here in detail.
[0151] Please refer to Figure 9 The first hash unit 131 comprises an account hash subunit 1311 and a tree hash subunit 1312.
[0152] The account hash subunit 1311 is configured to perform hash operations on the state data of the at least two subchain accounts in the total account state data respectively to obtain account state hash values respectively corresponding to the at least two subchain accounts.
[0153] The tree hash subunit 1312 is configured to hash the account state hash values corresponding to the at least two subchain accounts according to the state Merkle tree path, to obtain a root hash value, and determine the root hash value as the first state hash value.
[0154] The specific implementation of the account hash subunit 1311 and the tree hash subunit 1312 can be referred to the description of the account hash subunit 1311 and the tree hash subunit 1312 in the above Figure 3 The description of step S103 in the corresponding embodiment will not be repeated here.
[0155] Please refer to the above Figure 9 The data processing apparatus 1 further includes a packaging module 15, a consensus module 16, and an updating module 17.
[0156] The packaging module 15 is configured to package the transaction data into a to-be-chained subchain block.
[0157] The consensus module 16 is configured to perform consensus processing on the to-be-chained subchain block after the zero-knowledge proof data is verified by the main chain node.
[0158] The updating module 17 is configured to update the total account state data in the account book of the subchain network to the to-be-verified total account state data after the consensus processing on the to-be-chained subchain block is passed.
[0159] The specific implementation of the packaging module 15, the consensus module 16, and the updating module 17 can be referred to the description of the packaging module 15, the consensus module 16, and the updating module 17 in the above Figure 3 The description of the optional embodiment in the corresponding embodiment will not be repeated here.
[0160] In the embodiment of the present application, after the relay node of the sub-blockchain network executes the transaction data for the target sub-chain account and obtains the transaction execution result, the relay node can obtain the total account state data in the sub-blockchain network, and then generate the to-be-verified total account state data according to the transaction execution result and the total account state data, and generate the zero-knowledge proof data according to the total account state data and the to-be-verified total account state data. Finally, the relay node submits the zero-knowledge proof data and the state change information associated with the transaction execution result to the main-chain node of the main-blockchain network, and the main-chain node can change the state data of the target main-chain account according to the state change information when the zero-knowledge proof data is proved and verified. The total account state data includes the state data of at least two sub-chain accounts, and the at least two sub-chain accounts include the target sub-chain account. The target sub-chain account and the target main-chain account are associated. Through the method provided in the embodiment of the present application, the main-chain account in the main-blockchain network is associated with the sub-chain account in the sub-blockchain network, the transaction logic for the target main-chain account is converted into the transaction data for the target sub-chain account, and then the transaction data is executed in the relay node of the sub-blockchain network. The main-chain node verifies the zero-knowledge proof data generated after the relay node executes the transaction data, and the state data of the main-chain account can be changed according to the state change information after the verification is passed, which saves the time for the main-chain node to execute the transaction, greatly improves the TPS of the main-blockchain network, and in addition, the execution data related to the transaction data in the sub-blockchain network does not need to be submitted to the main-blockchain network, which also relieves the transaction storage pressure in the main-blockchain network.
[0161] See Figure 10 , Figure 10 is a structural schematic diagram of a computer device provided in the embodiment of the present application. As shown in Figure 10 , the computer device 1000 can include a processor 1001, a network interface 1004 and a memory 1005, in addition, the computer device 1000 can further include a user interface 1003 and at least one communication bus 1002. The communication bus 1002 is used to realize the connection and communication between the components. The user interface 1003 can include a display, a keyboard, and the optional user interface 1003 can further include a standard wired interface, a wireless interface. The network interface 1004 can optionally include a standard wired interface, a wireless interface (such as a WI-FI interface). The memory 1005 can be a high-speed RAM memory, or a non-volatile memory, for example, at least one disk memory. The memory 1005 can be optionally at least one storage device located away from the aforementioned processor 1001. As shown in Figure 10As shown, the memory 1005 as a computer readable storage medium can include an operating system, a network communication module, a user interface module, and a device control application.
[0162] In the computer device 1000 as shown, the network interface 1004 can provide a network communication element; the user interface 1003 is mainly used to provide an interface for user input; and the processor 1001 can be used to invoke the device control application stored in the memory 1005 to implement: Figure 10
[0163] execute the transaction data for the target sub-chain account to obtain a transaction execution result; the relay node belongs to a sub-block chain network;
[0164] obtain total account state data in the sub-block chain network, generate to-be-verified total account state data according to the transaction execution result and the total account state data; the total account state data includes state data of at least two sub-chain accounts, and the at least two sub-chain accounts include the target sub-chain account;
[0165] generate zero-knowledge proof data according to the total account state data and the to-be-verified total account state data;
[0166] submit the zero-knowledge proof data and state change information associated with the transaction execution result to a main chain node, so that the main chain node changes state data of a target main chain account according to the state change information when the zero-knowledge proof data is proved and verified; the target sub-chain account and the target main chain account are associated; and the main chain node belongs to a main block chain network.
[0167] It should be understood that the computer device 1000 described in the embodiments of the present application can execute the foregoing Figure 3 description of the data processing method in any of the corresponding embodiments, which will not be repeated here. In addition, the description of the beneficial effects of using the same method will also not be repeated.
[0168] In addition, it should be noted that the embodiments of the present application also provide a computer readable storage medium, and the aforementioned computer readable storage medium stores the computer program executed by the aforementioned data processing device 1, and the aforementioned computer program includes program instructions, and when the aforementioned processor executes the aforementioned program instructions, the foregoing Figure 3 description of the data processing method in any of the corresponding embodiments, which will not be repeated here. In addition, the description of the beneficial effects of using the same method will also not be repeated. For technical details not disclosed in the computer readable storage medium embodiments involved in the present application, please refer to the description of the method embodiments of the present application.
[0169] Further, please refer to Figure 11 ,Figure 11 is another structural schematic diagram of a data processing apparatus based on a block chain provided by an embodiment of the present application. The data processing apparatus can be a computer program (including program code) running in a computer device, for example, the data processing apparatus is an application software; the apparatus can be used to execute corresponding steps in the method provided by the embodiments of the present application. As shown in the figure, the data processing apparatus 2 can include a receiving module 21, a proof verification module 22 and a change module 23. Figure 11
[0170] The receiving module 21 is configured to receive zero-knowledge proof data submitted by a relay node and state change information associated with a transaction execution result; the main chain node belongs to a main block chain network; the relay node belongs to a sub block chain network; the zero-knowledge proof data is generated according to total account state data of the sub block chain network and to-be-verified total account state data; the to-be-verified total account state data is generated according to a transaction execution result and the total account state data; the transaction execution result is obtained by the relay node executing transaction data for a target sub chain account;
[0171] The proof verification module 22 is configured to call a proof contract to perform proof verification on the zero-knowledge proof data, and obtain a proof verification result.
[0172] The change module 23 is configured to change state data of a target main chain account according to the state change information if the proof verification result is a proof verification pass result; the target sub chain account and the target main chain account are associated.
[0173] The specific implementation of the receiving module 21, the proof verification module 22 and the change module 23 can be referred to the description of steps S201-S203 in the above-mentioned corresponding embodiments, which will not be repeated here. Figure 4
[0174] The state data of the target main chain account includes on-chain state data and contract state data of the target main chain account; the on-chain state data is used to represent on-chain virtual resources owned by the target main chain account in the main block chain network and not locked in a resource lock contract; the contract state data is used to represent contract virtual resources owned by the target main chain account in the main block chain network and locked in the resource lock contract;
[0175] Please refer to Figure 11 The change module 23 includes a first change unit 231 and a second change unit 232.
[0176] The first change unit 231 is configured to perform state change on the on-chain state data and the contract state data of the target main chain account according to the state change information if the transaction data belongs to a first transaction business type.
[0177] The second changing unit 232 is configured to change the contract state data of the target main chain account according to the state changing information if the transaction data belongs to the second transaction business type.
[0178] The specific implementation of the first changing unit 231 and the second changing unit 232 can refer to the description of step S203 in the above Figure 4 The description of step S203 in the above
[0179] The first transaction business type is a storage business type, and the state changing information includes a target main chain account used for performing the storage business and target storage state data.
[0180] The description of step S203 in the above Figure 11 The first changing unit 231 includes a first transfer sub-unit 2311 and a storage changing sub-unit 2312.
[0181] The first transfer sub-unit 2311 is configured to obtain, as storage virtual resource, a virtual resource corresponding to the target storage state data in the virtual resource corresponding to the target main chain account if the transaction data belongs to the storage business type.
[0182] The first transfer sub-unit 2311 is further configured to transfer the storage virtual resource to the resource locking contract for locking.
[0183] The storage changing sub-unit 2312 is configured to subtract the on-chain state data from the target storage state data to obtain the on-chain state data after the state changing.
[0184] The storage changing sub-unit 2312 is further configured to add the contract state data and the target storage state data to obtain the contract state data after the state changing.
[0185] The specific implementation of the first transfer sub-unit 2311 and the storage changing sub-unit 2312 can refer to the description of step S203 in the above Figure 4 The description of step S203 in the above
[0186] The first transaction business type is a withdrawal business type, and the state changing information includes a target main chain account used for performing the withdrawal business and target withdrawal state data.
[0187] The description of step S203 in the above Figure 11 The first changing unit 231 includes a second transfer sub-unit 2313 and a withdrawal changing sub-unit 2314.
[0188] The second transfer sub-unit 2313 is configured to, if the transaction data belongs to the extraction business type, obtain a virtual resource corresponding to the target extraction state data in the contract virtual resource corresponding to the target main chain account as an extraction virtual resource.
[0189] The second transfer sub-unit 2313 is further configured to transfer the extraction virtual resource out of the resource locking contract.
[0190] The extraction change sub-unit 2314 is configured to add the on-chain state data and the target extraction state data to obtain the on-chain state data after state change.
[0191] The extraction change sub-unit 2314 is further configured to subtract the contract state data and the target extraction state data to obtain the contract state data after state change.
[0192] The specific implementation of the second transfer sub-unit 2313 and the extraction change sub-unit 2314 can be referred to the description of step S203 in the above-mentioned Figure 4 embodiment, and details will not be repeated here.
[0193] The second transaction business type is a transfer business type, and the state change information includes a target main chain account used for performing the transfer business and target transfer state data.
[0194] Please refer to Figure 11 The second change unit 232 includes a subtraction sub-unit 2321 and an addition sub-unit 2322.
[0195] The subtraction sub-unit 2321 is configured to, if the transaction data belongs to the transfer business type, subtract the contract state data of the first main chain account and the target transfer state data to obtain the contract state data of the first main chain account after state change.
[0196] The addition sub-unit 2322 is configured to add the contract state data of the second main chain account and the target transfer state data to obtain the contract state data of the second main chain account after state change.
[0197] The specific implementation of the subtraction sub-unit 2321 and the addition sub-unit 2322 can be referred to the description of step S203 in the above-mentioned Figure 4 embodiment, and details will not be repeated here.
[0198] Please refer to Figure 11 The data processing apparatus 2 further includes an address creation module 24 and an account creation module 25.
[0199] The address creation module 24 is configured to receive a contract address creation request for the target main chain account sent by the service node.
[0200] The address creation module 24 is further configured to create, according to the contract address creation request, a contract address bound to the target main chain account in the resource lock contract as a target contract address; the target contract address is configured to store contract state data of the target main chain account.
[0201] The account creation module 25 is configured to generate, according to the contract address creation request, an account address creation request to the relay node, so that the relay node creates, according to the account address creation request, a subchain account address bound to the target subchain account associated with the target main chain account in the subblockchain network; the subchain account address is configured to store state data of the target subchain account.
[0202] The specific implementation of the address creation module 24 and the account creation module 25 can be referred to the above Figure 4 optional description in the above
[0203] In the embodiment, the virtual resource in the main blockchain network can be transferred to the resource lock contract for storage, the virtual resource stored in the resource lock contract will be a contract virtual resource, the execution process of the transaction data related to the contract virtual resource in the main blockchain network is transferred to the subblockchain network for execution to obtain a transaction execution result, the main chain node only needs to receive the zero-knowledge proof data submitted by the relay node and the state change information associated with the transaction execution result, and then call the proof contract to prove and verify the zero-knowledge proof data to obtain a proof verification result, and according to the state change information, the state data of the target main chain account is changed when the proof verification result is a proof verification pass result, which saves the time of the main chain node to execute the transaction, greatly improves the TPS of the main blockchain network, and the execution data related to the transaction data in the subblockchain network does not need to be submitted to the main blockchain network, which also relieves the transaction storage pressure in the main blockchain network. In addition, the on-chain virtual resource in the main blockchain network that is not stored in the resource lock contract can be normally traded, which greatly improves the flexibility of the main blockchain network for virtual resource transactions and speeds up the transaction processing speed.
[0204] Further, please refer to Figure 12 , Figure 12 is another structural schematic diagram of a computer device provided in the embodiment. As shown in Figure 12 the above Figure 11The data processing device 2 in the corresponding embodiment can be applied to the aforementioned computer device 2000. The computer device 2000 may include a processor 2001, a network interface 2004, and a memory 2005. Furthermore, the computer device 2000 also includes a user interface 2003 and at least one communication bus 2002. The communication bus 2002 is used to enable communication between these components. The user interface 2003 may include a display screen and a keyboard; optionally, the user interface 2003 may also include a standard wired interface or a wireless interface. The network interface 2004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 2005 may be high-speed RAM or non-volatile memory, such as at least one disk storage device. Optionally, the memory 2005 may also be at least one storage device located remotely from the aforementioned processor 2001. Figure 12 As shown, the memory 2005, which is a computer-readable storage medium, may include an operating system, a network communication module, a user interface module, and a device control application program.
[0205] exist Figure 12 In the computer device 2000 shown, the network interface 2004 provides network communication functionality; the user interface 2003 is mainly used to provide an input interface for the user; and the processor 2001 can be used to call the device control application program stored in the memory 2005 to achieve:
[0206] The system receives zero-knowledge proof data submitted by relay nodes, along with state change information associated with transaction execution results. Main chain nodes belong to the main blockchain network; relay nodes belong to sub-blockchain networks. Zero-knowledge proof data is generated based on the total account state data of the sub-blockchain network and the total account state data to be verified. The total account state data to be verified is generated based on the transaction execution results and the total account state data. Transaction execution results are obtained by relay nodes executing transaction data targeting the specific sub-chain account.
[0207] The proof contract is invoked to verify the zero-knowledge proof data, and the proof verification result is obtained.
[0208] If the verification result is that the verification is successful, then the state data of the target main chain account is changed according to the state change information; the target sub-chain account and the target main chain account are associated.
[0209] It should be understood that the computer device 2000 described in the embodiments of this application can execute the access control method described in the preceding embodiments, and can also execute the methods described in the preceding embodiments. Figure 11The description of the data processing device 2 in the corresponding embodiment will not be repeated here. In addition, the beneficial effects of using the same method will not be repeated here.
[0210] In addition, it should be noted that the embodiments of the present application also provide a computer readable storage medium, and the computer readable storage medium stores the computer program executed by the data processing device 2 mentioned above. When the processor loads and executes the computer program, the computer program can execute the description of the access control method in any of the preceding embodiments, and therefore, the description will not be repeated here. In addition, the beneficial effects of using the same method will not be repeated here. For technical details of the computer readable storage medium embodiments involved in the present application, please refer to the description of the method embodiments of the present application.
[0211] The computer readable storage medium can be an internal storage unit of the data processing device or the computer device, such as a hard disk or a 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 disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. Further, the computer readable storage medium can include both the internal storage unit and the external storage device 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.
[0212] In addition, it should be noted that the embodiments of the present application also provide a computer program product or a computer program, which includes computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to make the computer device execute the description of the access control method in any of the preceding embodiments. Figure 3 、 Figure 4 The method provided by any of the corresponding embodiments.
[0213] The terms "first", "second", etc. in the specification and claims of the present application and the drawings are used to distinguish different objects, and are not used to describe a particular order. In addition, the term "comprising" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, device, product or apparatus that includes a series of steps or units is not limited to the listed steps or units, but can optionally include steps or units not listed, or can optionally include other steps or units inherent to such processes, methods, devices, products or apparatus.
[0214] Those skilled in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized in electronic hardware, computer software or a combination of both. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been described in the above description in a general manner. Whether the net element is executed in hardware or software depends on the specific application and design constraints of the technical solution. The skilled person can use different methods to implement the described net element for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0215] The above disclosure is only the preferred embodiment of the present application, and of course cannot limit the scope of the right of the present application, so the equivalent changes made according to the claims of the present application are still within the scope of the present application.
Claims
1. A blockchain-based data processing method, characterized in that, The method comprises the following steps: The relay node executes transaction data for a target subchain account in a to-be-uplinked subchain block, and obtains a transaction execution result; The relay node belongs to a subchain network; Obtain total account state data in the subchain network, and generate to-be-verified total account state data according to the transaction execution result and the total account state data; the total account state data comprises state data of at least two subchain accounts, and the at least two subchain accounts comprise the target subchain account; The to-be-verified total account state data is used to indicate that total account state data in the subchain network has not been changed based on the transaction execution result; Generate zero-knowledge proof data according to the total account state data and the to-be-verified total account state data; Submit the zero-knowledge proof data and state change information associated with the transaction execution result to a main chain node, so that the main chain node changes state data of a target main chain account according to the state change information when the zero-knowledge proof data is proved to be verified; the target subchain account and the target main chain account are associated; The main chain node belongs to a main chain network; After the main chain node proves the zero-knowledge proof data to be verified, consensus processing is performed on the to-be-uplinked subchain block; After the to-be-uplinked subchain block is consensus processed, the to-be-uplinked subchain block is stored in a logical subchain in the subchain network, and the total account state data in the account book of the subchain network is updated to the to-be-verified total account state data.
2. The method of claim 1, wherein, The generation of the zero-knowledge proof data according to the total account state data and the to-be-verified total account state data comprises the following steps: Hash processing is performed on the total account state data to obtain a first state hash value; Hash processing is performed on the to-be-verified total account state data to obtain a second state hash value; According to the total account state data and the to-be-verified total account state data, state data change values corresponding to the at least two subchain accounts are determined respectively; The first state hash value, the second state hash value and the state data change value are input into a zero-knowledge proof circuit to obtain zero-knowledge proof data.
3. The method of claim 1, wherein, The hash processing on the total account state data to obtain the first state hash value comprises the following steps: Hash operations are respectively performed on the state data of the at least two subchain accounts in the total account state data to obtain account state hash values corresponding to the at least two subchain accounts respectively; According to a state Merkle tree path, hash operations are performed on the account state hash values corresponding to the at least two subchain accounts respectively to obtain a root hash value, and the root hash value is determined as the first state hash value. 4.A blockchain-based data processing method, characterized in that, The method comprises the following steps: A main chain node receives zero-knowledge proof data and state change information associated with a transaction execution result submitted by a relay node; The main chain node belongs to a main chain network; The relay node belongs to a subchain network; the zero-knowledge proof data is generated according to total account state data and to-be-verified total account state data of the subchain network; The to-be-verified account total state data is generated according to the transaction execution result and the account total state data; the transaction execution result is obtained by the relay node executing transaction data for a target subchain account in a to-be-chained subchain block; The to-be-verified account total state data is used to indicate that the account total state data in the subchain network has not been changed based on the transaction execution result; The proof contract is called to prove and verify the zero-knowledge proof data, and a proof verification result is obtained; If the proof verification result is a proof verification pass result, the state data of the target main chain account is changed according to the state change information; the target subchain account and the target main chain account are associated; the relay node is also used to, after the main chain node proves and verifies the zero-knowledge proof data, perform consensus processing on the to-be-chained subchain block, and is used to, when the to-be-chained subchain block consensus processing passes, store the to-be-chained subchain block to a logical subchain in the subchain network, and update the account total state data in the account book of the subchain network to the to-be-verified account total state data.
5. The method of claim 4, wherein, The state data of the target main chain account includes on-chain state data and contract state data of the target main chain account; the on-chain state data is used to represent on-chain virtual resources owned by the target main chain account in the main chain network and not locked in a resource lock contract; the contract state data is used to represent contract virtual resources owned by the target main chain account in the main chain network and locked in the resource lock contract; The state data of the target main chain account is changed according to the state change information, including: If the transaction data belongs to a first transaction business type, the on-chain state data and the contract state data of the target main chain account are changed according to the state change information; If the transaction data belongs to a second transaction business type, the contract state data of the target main chain account is changed according to the state change information.
6. The method of claim 5, wherein, The first transaction business type is a storage business type, and the state change information includes the target main chain account used to execute the storage business and target storage state data; If the transaction data belongs to the storage business type, the virtual resource corresponding to the target storage state data is obtained as a storage virtual resource in the on-chain virtual resource corresponding to the target main chain account; The storage virtual resource is transferred to the resource lock contract for locking; The on-chain state data is subtracted from the target storage state data to obtain state-changed on-chain state data; The contract state data is added to the target storage state data to obtain state-changed contract state data. 7. The method of claim 5, wherein, The first transaction service type is a withdrawal service type, and the state change information includes the target main chain account used for performing the withdrawal service and target withdrawal state data; If the transaction data belongs to the first transaction service type, the on-chain state data and the contract state data of the target main chain account are changed according to the state change information, including: If the transaction data belongs to the withdrawal service type, the virtual resource corresponding to the target withdrawal state data is obtained from the contract virtual resource corresponding to the target main chain account as a withdrawal virtual resource; The withdrawal virtual resource is transferred out of the resource locking contract; The on-chain state data and the target withdrawal state data are added to obtain the on-chain state data after the state change; The contract state data and the target withdrawal state data are subtracted to obtain the contract state data after the state change.
8. The method of claim 5, wherein, The second transaction service type is a transfer service type, and the state change information includes the target main chain account used for performing the transfer service and target transfer state data; the target main chain account includes a first main chain account and a second main chain account; If the transaction data belongs to the second transaction service type, the contract state data of the target main chain account is changed according to the state change information, including: If the transaction data belongs to the transfer service type, the contract state data of the first main chain account and the target transfer state data are subtracted to obtain the contract state data after the state change corresponding to the first main chain account; The contract state data of the second main chain account and the target transfer state data are added to obtain the contract state data after the state change corresponding to the second main chain account.
9. The method of claim 5, wherein, Further comprising: receiving a contract address creation request for a target main chain account sent by a service node; creating a contract address bound to the target main chain account in the resource locking contract as a target contract address according to the contract address creation request; The target contract address is used to store the contract state data of the target main chain account; According to the contract address creation request, an account address creation request is generated to a relay node, so that the relay node creates a subchain account address bound to a target subchain account associated with the target main chain account in the subblockchain network according to the account address creation request; the subchain account address is used to store the state data of the target subchain account. 10.A data processing apparatus based on a blockchain, the data processing apparatus being applied to a relay node, characterized in that, Comprising: an execution module configured to execute transaction data for a target subchain account in a to-be-chained subblock, to obtain a transaction execution result; The relay node belongs to a subblockchain network; a state generation module configured to obtain total account state data in the subblockchain network, and generate to-be-verified total account state data according to the transaction execution result and the total account state data; the total account state data includes state data of at least two subchain accounts, and the at least two subchain accounts include the target subchain account; The to-be-verified account total state data is used to indicate that the account total state data in the sub-blockchain network has not been changed based on the transaction execution result; The proof generation module is configured to generate zero-knowledge proof data based on the account total state data and the to-be-verified account total state data; The submission module is configured to submit the zero-knowledge proof data and state change information associated with the transaction execution result to a main chain node, so that the main chain node changes the state data of a target main chain account according to the state change information when the zero-knowledge proof data is proved to be verified; the target sub-chain account and the target main chain account are associated; and the main chain node belongs to a main blockchain network. The consensus module is configured to perform consensus processing on the to-be-chained sub-chain block after the main chain node proves the zero-knowledge proof data to be verified. The update module is configured to store the to-be-chained sub-chain block to a logical sub-chain in the sub-blockchain network when the to-be-chained sub-chain block is consensus-processed, and update the account total state data in the account book of the sub-blockchain network to the to-be-verified account total state data. 11.A data processing apparatus based on a blockchain, the data processing apparatus being applied to a main chain node, characterized in that, Comprise: The receiving module is configured to receive zero-knowledge proof data and state change information associated with a transaction execution result submitted by a relay node; The main chain node belongs to a main blockchain network; The relay node belongs to a sub-blockchain network; and the zero-knowledge proof data is generated based on account total state data and to-be-verified account total state data of the sub-blockchain network; The to-be-verified account total state data is generated based on the transaction execution result and the account total state data; and the transaction execution result is obtained by the relay node executing transaction data for a target sub-chain account in a to-be-chained sub-chain block; The to-be-verified account total state data is used to indicate that the account total state data in the sub-blockchain network has not been changed based on the transaction execution result; The proof verification module is configured to call a proof contract to prove and verify the zero-knowledge proof data, and obtain a proof verification result; The change module is configured to change the state data of a target main chain account according to the state change information if the proof verification result is a proof verification pass result; the target sub-chain account and the target main chain account are associated; the relay node is further configured to perform consensus processing on the to-be-chained sub-chain block after the main chain node proves the zero-knowledge proof data to be verified, and store the to-be-chained sub-chain block to a logical sub-chain in the sub-blockchain network when the to-be-chained sub-chain block is consensus-processed, and update the account total state data in the account book of the sub-blockchain network to the to-be-verified account total state data.
12. A computer device, comprising: Comprise: A processor, a memory and a network interface; The processor is connected with the memory and the network interface, wherein the network interface is configured to provide data communication function, the memory is configured to store program code, and the processor is configured to call the program code to execute the method in any one of claims 1-9.
13. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is suitable for being loaded and executed by the processor to execute the method in any one of claims 1-9.
14. A computer program product comprising computer programs / instructions, characterized in that, The computer program / instruction is executed by the processor to execute the method in any one of claims 1-9.
Citation Information
Patent Citations
Multi-layer hybrid transaction capacity expansion system and method for block chain
CN113269543A