Blockchain-based data processing methods, devices, equipment, media and products

By generating anchor data through the chain exchange model and executing data chain exchange transactions, the problems of resource waste and data incompleteness in blockchain data migration are solved, efficient and secure data synchronization and storage are achieved, and maintenance costs are reduced.

CN116541370BActive Publication Date: 2025-09-16TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210090742.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-25
Publication Date
2025-09-16
Estimated Expiration
2042-01-25

AI Technical Summary

Technical Problem

Existing technologies have problems in the blockchain data migration process, such as resource waste, high maintenance costs, slow migration speed, incomplete and unverifiable data. Especially under cross-chain technology and direct migration methods, it is impossible to effectively synchronize the original chain status data and ensure data integrity.

Method used

A chain-swapping model is adopted to generate anchor data for the state data to be chain-swapped and execute a data chain-swapping transaction, adding it to the second blockchain. At the same time, transaction and block information are stored off-chain, and smart contracts and multi-signature methods are used to ensure data integrity and verifiability.

Benefits of technology

It achieves efficient synchronization of the original chain status data, reduces the storage burden of the new chain, ensures data integrity and credibility, improves the efficiency and security of chain switching, and reduces maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116541370B_ABST
    Figure CN116541370B_ABST
Patent Text Reader

Abstract

This application provides a blockchain-based data processing method, apparatus, device, medium, and product, wherein the method includes: in response to a chain swap operation, obtaining the chain state data to be swapped from the first state database of a first blockchain, and obtaining the anchor data to be uploaded to the chain of the first blockchain; executing a data chain swap transaction based on the chain state data to be swapped, adding the chain state data to the second blockchain, and storing the chain state data to be swapped in the second state database of the second blockchain; executing a data on-chain transaction based on the anchor data to be uploaded, adding the anchor data to the second blockchain, and storing the target transaction data and block information contained in the block to be processed in an off-chain database. This application can realize blockchain data chain swapping, which is beneficial for blockchain synchronization of new chain nodes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of blockchain technology, and in particular to a blockchain-based data processing method, a blockchain-based data processing device, a data processing equipment, a computer-readable storage medium, and a computer program product. Background Art

[0002] With the continuous development and application of computer technology, blockchain technology has also developed rapidly, resulting in the emergence of many new blockchain platforms. Given that information stored on blockchains cannot be forged or tampered with, more and more users are storing their business data on blockchains. However, when users need to switch to a new blockchain platform due to insufficient performance or complex architecture on the original chain, they need to migrate the blockchain data from the original chain to complete the chain change. How to migrate the blockchain data on the original chain to complete the chain change operation is currently a pressing issue. Summary of the Invention

[0003] This application provides a blockchain-based data processing method, device, equipment, medium and product, which can reduce the storage pressure of the new chain on the basis of realizing blockchain data chain exchange, and is conducive to the blockchain synchronization of the new chain nodes.

[0004] This application provides a data processing method based on blockchain, which includes:

[0005] In response to the chain-swap operation, obtaining the chain-swap state data to be exchanged and the anchor data to be uploaded to the chain of the first blockchain from the first state database of the first blockchain; wherein the anchor data to be uploaded to the chain is generated based on the identification information of the target transaction data, the target transaction data is included in the block to be processed, and the block to be processed is a block on the first blockchain;

[0006] executing a data chain-for-chain transaction based on the chain-for-chain state data, adding the chain-for-chain state data to the second blockchain, and, after adding the chain-for-chain state data to the second blockchain, storing the chain-for-chain state data in a second state database of the second blockchain, so that the blockchain node generates blocks based on the state data stored in the second state database;

[0007] Execute data on-chain transactions based on the anchored data to be on-chain, add the anchored data to be on-chain to the second blockchain, and store the target transaction data and block information contained in the block to be processed in an off-chain database, so that the blockchain node can query the target transaction data from the off-chain database based on the anchored data on the second blockchain.

[0008] This application provides another data processing method based on blockchain, which includes:

[0009] In response to a transaction data query request for the second blockchain, querying the transaction data stored on the second blockchain based on the query identifier carried in the transaction data query request;

[0010] If the query transaction data corresponding to the query identifier is not found, the anchor data stored on the second blockchain is queried based on the query identifier; wherein the anchor data is generated based on the identification information of the target transaction data, the target transaction data is included in the block to be processed, and the block to be processed is a block on the first blockchain; the anchor data stored on the second blockchain is added to the second blockchain when a data on-chain transaction is executed based on the anchor data corresponding to the first blockchain in response to the chain switching operation;

[0011] If the anchor data corresponding to the query identifier is found, the query transaction data corresponding to the query identifier is queried from the off-chain database based on the query identifier; wherein the off-chain database stores the target transaction data and block information contained in the block to be processed, and the target transaction data and block information are added to the off-chain database in response to the chain switching operation.

[0012] This application provides a blockchain-based data processing device, which is applied in one embodiment and includes:

[0013] a data migration module, configured to, in response to a chain-swap operation, obtain, from a first state database of a first blockchain, state data for the chain to be swapped, and obtain anchor data to be uploaded to the chain of the first blockchain; wherein the anchor data to be uploaded to the chain is generated based on identification information of target transaction data, the target transaction data is included in a block to be processed, and the block to be processed is a block on the first blockchain;

[0014] The data migration module is further configured to execute a data chain-swap transaction based on the chain-to-be-swapped state data, add the chain-to-be-swapped state data to the second blockchain, and, after adding the chain-to-be-swapped state data to the second blockchain, store the chain-to-be-swapped state data in a second state database of the second blockchain, so that the blockchain node generates blocks based on the state data stored in the second state database.

[0015] The above-mentioned data migration module is also used to perform data on-chain transactions based on the above-mentioned anchored data to be on-chain, add the above-mentioned anchored data to be on-chain to the above-mentioned second blockchain, and store the above-mentioned target transaction data and block information contained in the above-mentioned block to be processed in an off-chain database, so that the blockchain node can query the above-mentioned target transaction data from the above-mentioned off-chain database based on the anchored data on the above-mentioned second blockchain.

[0016] The device is applied to another embodiment, comprising:

[0017] a data query module, configured to respond to a transaction data query request for the second blockchain and query the transaction data stored on the second blockchain based on a query identifier carried in the transaction data query request;

[0018] The data query module is further configured to query the anchor data stored on the second blockchain based on the query identifier if the query transaction data corresponding to the query identifier is not found; wherein the anchor data is generated based on the identification information of the target transaction data, the target transaction data is included in the block to be processed, and the block to be processed is a block on the first blockchain; the anchor data stored on the second blockchain is added to the second blockchain when a data on-chain transaction is executed based on the anchor data corresponding to the first blockchain in response to the chain switching operation;

[0019] The above-mentioned data query module is also used to query the query transaction data corresponding to the above-mentioned query identifier from the off-chain database based on the above-mentioned query identifier if the anchor data corresponding to the above-mentioned query identifier is queried; wherein the above-mentioned off-chain database stores the above-mentioned target transaction data and block information contained in the above-mentioned block to be processed, and the above-mentioned target transaction data and the above-mentioned block information are added to the above-mentioned off-chain database in response to the above-mentioned chain switching operation.

[0020] The present application provides a data processing device, comprising a processor, a memory, and a network interface, wherein the processor, memory, and network interface are interconnected, wherein the memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to call the program instructions to implement the steps of the above-mentioned blockchain-based data processing method.

[0021] The present application provides a computer-readable storage medium, which stores a computer program. The computer program includes program instructions, and the program instructions are executed by a processor to implement the steps of the above-mentioned blockchain-based data processing method.

[0022] The present application provides a computer program product, which includes a computer program or computer instructions. The computer program or computer instructions are executed by a processor to implement the steps of the above-mentioned blockchain-based data processing method.

[0023] The present application is to migrate the to-be-changed chain state data of the first blockchain to the second blockchain by executing a transaction method, that is, based on the to-be-changed chain state data, a data chain exchange transaction is executed to add the to-be-changed chain state data to the second blockchain to complete the chain exchange, so that after the migration is completed, the blockchain node of the second blockchain can directly synchronize the original chain state data by synchronizing the blocks on the chain, without having to synchronize through the original chain blocks, thereby improving the chain exchange efficiency; after adding the to-be-changed chain state data to the second blockchain, the to-be-changed chain state data and block information are also stored in the second state database of the second blockchain, thereby reducing the storage burden of the migration data on the second blockchain, and by generating the to-be-changed chain anchor data of the first blockchain, it is chained to the second blockchain, and then the state data in the second state database is verified according to the anchor data after chaining, thereby ensuring the data verifiability when the data is stored off-chain, improving the credibility of the off-chain stored data, and ensuring the security of the data during the chain exchange process. When generating blocks, blockchain nodes can directly obtain data from the state data stored in the second state database, thereby improving the efficiency of block generation. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0025] Figure 1a This is a schematic diagram of the architecture of a blockchain-based data processing system provided in an embodiment of the present application;

[0026] Figure 1b This is a schematic diagram of the structure of a blockchain provided by an embodiment of the present application;

[0027] Figure 1c This is a schematic diagram of a process for generating a new block provided by an embodiment of the present application;

[0028] Figure 2 This is a flowchart of a blockchain-based data processing method provided in an embodiment of the present application;

[0029] Figure 3 This is a flowchart of a blockchain chain swap provided by an embodiment of the present application;

[0030] Figure 4 This is a schematic block diagram of a blockchain-based data migration method provided in an embodiment of the present application;

[0031] Figure 5 This is a timing diagram of a blockchain-based data migration method provided in an embodiment of the present application;

[0032] Figure 6 This is a flowchart of another blockchain-based data processing method provided in an embodiment of the present application;

[0033] Figure 7 This is a schematic block diagram of a transaction query method based on blockchain provided in an embodiment of the present application;

[0034] Figure 8 This is a timing diagram of a blockchain-based transaction query method provided in an embodiment of the present application;

[0035] Figure 9 This is a schematic block diagram of a blockchain-based data processing device provided by the present embodiment;

[0036] Figure 10 This is a schematic block diagram of a data processing device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0037] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0038] It should be noted that the terms "first" and "second" in the embodiments of this application are for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a technical feature designated as "first" or "second" may explicitly or implicitly include at least one such feature.

[0039] The following describes some key terms used in the examples of this application. Chainmaker, an open-source underlying blockchain software platform, encompasses a core blockchain framework, a rich component library, and a toolkit. It is dedicated to efficiently and accurately addressing differentiated blockchain needs for users, building a high-performance, highly reliable, and secure new digital infrastructure. It is also China's first independently controlled blockchain hardware and software technology system. Changan Chain boasts advanced technological advantages such as high concurrency, low latency, and large-scale node networking, achieving a transaction throughput of 100,000 TPS (the number of transactions the system can process per second), placing it at the global leading level.

[0040] State data represents the latest values ​​of all keys in the blockchain's transaction information. (This data is stored in a key-value database, such as LevelDB, which is a persistent storage database. In this case, the key is the hash value, and the value is the block data.) Because state data represents all the latest key-value pairs known to the chain, it is also called the chain's world state. Blockchain contracts execute transaction proposals based on this state data.

[0041] Hyperledger Fabric (a distributed ledger technology) is a blockchain platform that provides distributed ledger solutions. Powered by a modular architecture, Hyperledger Fabric offers exceptional confidentiality, scalability, flexibility, and extensibility. Hyperledger Fabric is designed to support the seamless integration of different modular components and adapt to the diverse and complex scenarios of economic ecosystems. Throughout this application, "Fabric" will refer to Hyperledger Fabric, serving as the migration source chain (i.e., the first blockchain) mentioned in this proposal.

[0042] A smart contract is a computer protocol that, once developed and deployed, allows trusted transactions without a third party, achieving self-execution and self-verification. Technically, a smart contract can be considered a computer program that can autonomously execute all or part of the contract's operations and generate verifiable evidence demonstrating the validity of the executed operations. Transactions within a smart contract are traceable and irreversible. Before a smart contract is deployed, the logical flow of all relevant terms is defined. Smart contracts typically feature a user interface for users to interact with the contract, and these interactions strictly adhere to the defined logic. Cryptography allows these interactions to be rigorously verified to ensure that the contract executes according to the established rules, thus preventing potential breaches. Compared to traditional contracts, smart contracts offer improved security and uniqueness, using digitally defined commitments to ensure the security and reliability of the agreement between contract participants. A smart contract can consist of a set of digitally defined commitments and the protocol by which the contract participants can enforce these commitments.

[0043] The chain-swapping model, implemented in this application, is a model for migrating state data through transaction execution. If Fabric is used as the source chain for migration, it helps the migrator read the source chain's state data, block, and transaction data from the source chain's database file, construct a state data migration transaction, anchor the source chain transaction to the data transaction, and complete the migration transaction and the anchored data transaction on the target chain. The chain-swapping model can be understood as a tool to assist users who wish to switch chains. For example, some users may wish to replace the Fabric blockchain with the Chairmaker blockchain due to insufficient TPS, lack of national encryption support, or complex architecture. This chain-swapping model can be used to accomplish this. The chain-swapping model can be built based on the data migration model and transaction query model proposed in this application.

[0044] Namespaces specifically refer to the namespaces of smart contracts in blockchains. Blockchain systems use smart contract namespaces to isolate state data generated by different smart contracts.

[0045] Anchor data, as used in this application, refers to data used to verify whether a transaction is part of the Fabric original chain. The storage of txHash (transaction hash, also known as transaction ID) and txStatus (transaction status value) information can help users verify the validity and integrity of off-chain transactions. Anchor data must be stored on the target chain and cannot be tampered with.

[0046] Currently, there are two methods for blockchain chain switching operations. The first is a data migration solution from the original chain to the target chain based on a cross-chain technology solution. The second is a state data migration solution from the original chain to the new chain by directly migrating the fabric state database of the original chain to the target chain.

[0047] In the first case, using cross-chain technology to achieve the need to migrate the fabric to the target chain for chain switching has the problem of insufficient adaptability; when using cross-chain technology to migrate fabric state data, the original chain must still be alive, and users need to maintain two sets of blockchain systems, which wastes resources and has high maintenance costs; and using cross-chain technology to migrate fabric state data has a slow migration speed, complex function implementation, and high development costs.

[0048] In the second case, if the state data is directly migrated to the new chain state database, the newly added nodes will not be able to synchronize the original chain state data from the chain. The original chain data is directly stored in an off-chain database without the on-chain storage of anchored data, and the integrity of the off-chain stored data cannot be verified. There is a problem that the off-chain data cannot be verified if it has been tampered with. In addition, directly migrating the state data and writing it to the new chain state database may easily cause incomplete data storage on the new chain (for example, the chainmaker blockchain will have multiple databases that store information about state data writes separately, so if the state data is not written to the chain through a smart contract, it may easily cause incomplete data storage on the new chain). Furthermore, if the original chain node organizations do not trust each other, directly migrating the state data to the new chain state database means that each node needs to complete the entire migration work from scratch, which increases the complexity of the migration work and slows down the migration speed.

[0049] The method proposed in this application can achieve the following functions: using the chain-swap model to read state data from the fabric's original chain database and construct state data migration transactions based on the state data in different namespaces; the chain-swap model iterates over the fabric's original chain blocks and parses them to obtain fabric transaction data, from which it constructs transaction anchor data transactions on the original chain; after completing the construction of state data transactions and anchor data transactions, the chain-swap model facilitates the on-chain operation of these transactions on the new chain (i.e., the target blockchain) and stores the original fabric chain transactions and block information off-chain. Ultimately, this achieves state data migration from the original fabric chain to the new chain, as well as on-chain storage of the original chain's transaction anchor data.

[0050] The blockchain swap operation based on the method proposed in this application has the following effects:

[0051] 1. Migrate the fabric state data to the target chain by executing transactions. The target chain reaches consensus on the fabric migration transaction and then stores these migration transactions in blocks in the target chain database. This allows new nodes on the target chain to synchronize the fabric state data of the original chain directly with the transaction anchor data of the original chain by synchronizing blocks on the chain.

[0052] 2. Fabric original chain transactions and blocks are stored in an off-chain database, reducing the storage burden of the original chain data on the new chain (i.e., the second blockchain).

[0053] 3. Construct the original chain transaction anchor data on the migration target chain to ensure that the integrity of the original chain data can still be verified even if the fabric original chain transactions and blocks are stored in an off-chain database.

[0054] 4. Add the original chain status data of the fabric by calling the business smart contract of the migration target chain. The corresponding business smart contract writes the original chain status data into the namespace database corresponding to the original chain of the fabric to ensure that the original chain status data is still in the same namespace in the new chain.

[0055] 5. Use the off-chain multi-signature method, that is, use the multi-signature method of migration data to migrate data, to ensure that the on-chain migration data on the target chain is the on-chain data unanimously recognized by the members of the original chain organization.

[0056] This application will be described by the following examples:

[0057] See Figure 1a , is a schematic diagram of the architecture of a blockchain-based data processing system provided in an embodiment of the present application. The blockchain-based data processing system includes a blockchain network 10 and a client 102, wherein:

[0058] The blockchain network 10 refers to a network for sharing data between nodes. The blockchain network may include multiple nodes 101, wherein the multiple nodes 101 may include consensus nodes. Each node 101 may receive input information during normal operation and maintain the shared data (i.e., blockchain) within the blockchain network based on the received input information. Each node in the blockchain network stores an identical blockchain, which includes a series of blocks that are connected to each other in the order of their generation, such as Figure 1a As shown in Figure 1, Block M-1, and so on, once a new block is added to the blockchain, it cannot be removed. Blocks record the data submitted by nodes in the blockchain network. To ensure information interoperability within the blockchain network, each node can have an information connection, and any two nodes can achieve peer-to-peer (P2P) communication. P2P communication can be carried out via wired or wireless communication links. For example, when any node in the blockchain network receives input information, other nodes obtain this input information according to the consensus algorithm and store it as shared data, ensuring that the data stored on all nodes in the blockchain network is consistent.

[0059] The client 102 can access the blockchain network and communicate with nodes in the blockchain network, for example, sending transaction data to the nodes, etc. The terminal where the client 102 is located can be a smart phone, tablet computer, laptop computer, desktop computer, in-vehicle smart terminal, etc., which is not limited in the embodiments of the present application.

[0060] It should be noted that Figure 1aThe number of nodes shown in the figure is merely illustrative. Any number of nodes may be deployed according to actual needs. The node may refer to any form of computing device in the access network, such as a server or a user terminal, which may all join and become a node.

[0061] Each node in a blockchain network has a corresponding node identifier. Furthermore, each node in the blockchain network can store the node identifiers of other nodes in the network, allowing it to subsequently broadcast generated blocks to other nodes in the blockchain network based on those identifiers. Each node maintains a node identifier list, as shown in the table below, storing the node name and node identifier in this list. A node identifier can be an Internet Protocol (IP) address or any other information that can be used to identify the node. The table uses the IP address as an example.

[0062]

[0063] Each node in the blockchain network stores the same blockchain. The blockchain consists of multiple blocks, see Figure 1b The blockchain consists of multiple blocks. The genesis block includes a block header and a block body. The block header stores the input information feature value, version number, timestamp and difficulty value, and the block body stores the input information; the next block of the genesis block uses the genesis block as the parent block, and the next block also includes a block header and a block body. The block header stores the input information feature value of the current block, the block header feature value, version number, timestamp and difficulty value of the parent block, and so on, so that the block data stored in each block in the blockchain is associated with the block data stored in the parent block, ensuring the security of the input information in the block.

[0064] Among them, when generating each block in the blockchain, see Figure 1c When the node where the blockchain is located receives the input information, it verifies the input information. After the verification is completed, the input information is stored in the memory pool and the hash tree used to record the input information is updated. After that, the update timestamp is updated to the time when the input information is received, and different random numbers are tried. The eigenvalue calculation is performed multiple times so that the calculated eigenvalue can satisfy the following formula:

[0065]

[0066] in, SHA256 The eigenvalue algorithm used to calculate the eigenvalues; version (Version number) is the version information of the relevant block protocol in the blockchain; prev_hash The block header feature value of the parent block of the current block; merkle_root is the characteristic value of the input information; ntime The update time of the update timestamp; nbits The current difficulty is fixed for a period of time and is determined again after a fixed period of time. x is a random number; TARGET is the eigenvalue threshold, which can be calculated based on nbits Definitely got it.

[0067] Once a random number that satisfies the above formula is calculated, the information can be stored accordingly, generating a block header and block body, resulting in the current block. Subsequently, the blockchain node sends the newly generated block to other nodes in the blockchain network based on their node identifiers. These other nodes then verify the newly generated block and, upon completion, add it to their stored blockchain.

[0068] Smart contracts can run on nodes in a blockchain network, enabling various transactions to be carried out by invoking them. A smart contract is a tamper-proof, self-executing computer program running on a blockchain. A smart contract is a code implementation that executes when certain conditions are met. Developers can define the contract logic using a programming language and publish it to the blockchain (smart contract registration). Based on the contract terms, execution is triggered by calling a key or other event, completing the contract logic. Smart contracts can also be upgraded and deregistered.

[0069] In some feasible implementations, any node 101 of the blockchain network can obtain the transaction data of the client, and the transaction data can carry the identity of the client, which can be determined based on the identity certificate of the client. The node 101 can query the identity certificate of the client from the smart contract based on the identity. If the identity certificate of the client is queried from the smart contract, and it is determined based on the identity certificate that the client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain, then the node 101 can execute the transaction operation corresponding to the transaction data on the blockchain. The mapping relationship between the identity carried by the transaction data and the identity certificate recorded in the smart contract can be used to determine the identity certificate corresponding to the client, and the transaction operation can be performed according to the authority indicated in the identity certificate, thereby improving the security of data processing on the blockchain. Carrying only the identity in the transaction data can reduce the amount of transaction data compared to carrying a complete identity certificate in the transaction data, while ensuring that the corresponding identity certificate can be obtained, which is conducive to the rapid transmission of transaction data.

[0070] Usually, it is also necessary to generate transaction blocks for transaction data and upload the blocks to the chain (store the blocks on the blockchain). Since only identity identifiers are carried, the amount of transaction data can be reduced while ensuring that the corresponding identity certificate can be obtained, compared to carrying a complete identity certificate in the transaction data, so as to achieve a certain degree of data compression, which can reduce the consumption of blockchain storage resources.

[0071] It is understandable that in the specific implementation of this application, when blockchain status data, transaction data, user information and other related data are involved, when the embodiments of this application apply the above data to specific products or technologies, user permission or consent must be obtained, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.

[0072] The following is a detailed description of the implementation details of the technical solution of the embodiment of the present application:

[0073] See Figure 2 , Figure 2 This is a flowchart of a data processing method based on blockchain provided by an embodiment of the present application. The data processing method of the embodiment of the present application is mainly described from the perspective of the blockchain node. Figure 2 As shown, the blockchain-based data processing method may include:

[0074] S201. In response to a chain-swap operation, obtain chain-swap state data and anchor data to be uploaded to the first blockchain from a first state database of the first blockchain; wherein the anchor data to be uploaded to the first blockchain is generated based on identification information of target transaction data, the target transaction data is included in a block to be processed, and the block to be processed is a block on the first blockchain.

[0075] In an embodiment of the present application, if a user wishes to replace their original blockchain (e.g., the Fabric blockchain) with a new blockchain (e.g., the Chainmaker chain) because the original blockchain (e.g., the Fabric blockchain) is not performing as expected (e.g., due to insufficient TPS performance, lack of national security support, complex architecture, etc.), the method proposed in this application can be used to perform a chain switch operation after receiving the user's chain switch request. To respond to the chain switch operation, the blockchain data for the chain to be switched (typically, the state data of the migrating blockchain, i.e., the state data of the chain to be switched) must first be obtained. Because the information in the generative blocks on a blockchain is inherently unforgeable and tamper-proof, data verifiability must be ensured before block generation (specifically, during the chain switch process). This application verifies the integrity and validity of the state data of the chain to be switched by generating data verification information (i.e., the anchor data to be uploaded to the chain) corresponding to the state data of the chain to be switched, thereby improving the credibility of the data stored during the chain switch process. The target transaction data referred to above refers to the transaction data currently pending for processing. The target transaction data is contained in the pending block, which is a block on the first blockchain.

[0076] In one embodiment, identification information of the target transaction data can be obtained. For example, the target transaction data may include version (the version rule referenced by the transaction), numInputs (the number of inputs included in the transaction), inputs (the input data included in the transaction), numOutputs (the number of outputs included in the transaction), outputs (the output data included in the transaction), lockTime (the transaction lock time), etc. Inputs and outputs may include various sub-data representing the characteristics of the target transaction data. Therefore, based on the actual business situation, multiple data items can be selected and combined from the transaction data to obtain the identification information of the target transaction data. In subsequent processing, the required data can be directly obtained from the identification information of the target transaction data based on the transaction identifier of the target transaction data (for example, the anchor data to be uploaded to the chain can be obtained from the identification information of the target transaction data), thereby reducing the amount of data processing and improving processing efficiency.

[0077] In one embodiment, the anchor data to be uploaded to the first blockchain can be generated based on the identification information of the target transaction data. The anchor data to be uploaded to the first blockchain includes the data required for the on-chain operation. For example, the format of the anchor data to be uploaded to the first blockchain is shown in the following table.

[0078]

[0079] The valid status value of the transaction data specifically refers to whether the transaction data is valid (for example, when the transaction data is verified to have not been tampered with, the transaction data is determined to be valid); the height of the block to which the transaction belongs specifically refers to the height at which the transaction data is uploaded to the chain, which can be understood as the block order of the blocks in the blockchain corresponding to the transaction; the order of transactions in the block specifically refers to the transaction order of the transaction data in the block to which it belongs.

[0080] In one embodiment, a blockchain typically includes numerous nodes. However, excessive communication between nodes consumes excessive bandwidth. Therefore, a blockchain node can be designated as an execution node (also known as a master node) to perform relevant operations. Master node designation can be implemented in two ways: static designation, where a blockchain administrator pre-configures and selects a node as the master node. (If the blockchain is divided into multiple partitions, each partition has a master node. In this case, multiple nodes can be designated as master nodes for each partition; if multiple partitions are merged into one, the number of master nodes can be reduced to one.) Dynamic election, where nodes vote to select a master node. For example, when multiple nodes declare themselves master nodes, they can be sorted according to their node identities (also known as node IDs), and the node with the smallest node ID is selected as the master node.

[0081] The above process of obtaining the state data of the chain to be exchanged from the first state database of the first blockchain can be achieved by the following method:

[0082] Obtain the to-be-swapped chain state data corresponding to the target smart contract from the first state database of the first blockchain.

[0083] In this embodiment, blockchain state data is stored in a state database. The blockchain state data contains the corresponding smart contracts for transactions. Smart contracts allow for trusted transactions without a third party. Transactions within the blockchain require the use of corresponding smart contracts. Therefore, the state data for the chain to be swapped can be categorized based on the smart contracts it corresponds to, facilitating subsequent storage of state data corresponding to different smart contracts.

[0084] In one embodiment, the target smart contract to be processed can be first determined, and then the pending chain state data under the smart contract can be queried in the first state database of the first blockchain. The target smart contract can be one or more. When there are multiple target smart contracts, a subset of the pending chain state data under each smart contract can be obtained, and the multiple pending chain state data subsets can be used as the pending chain state data.

[0085] It should be noted that this application does not limit the execution steps for obtaining the pending chain-swap state data and the pending chain-upload anchor data of the first blockchain from the first state database of the first blockchain. The pending chain-swap state data can be obtained first, followed by the pending chain-upload anchor data; the pending chain-upload anchor data can also be obtained first, followed by the pending chain-swap state data; and the pending chain-swap state data or the pending chain-upload anchor data can also be obtained when the pending chain-swap state data or the pending chain-upload anchor data are used in subsequent operations. The specific execution order can be adjusted according to actual circumstances to achieve more efficient chain switching.

[0086] S202: Execute a data chain-for-chain transaction based on the chain-for-chain state data, add the chain-for-chain state data to the second blockchain, and after adding the chain-for-chain state data to the second blockchain, store the chain-for-chain state data in a second state database of the second blockchain, so that the blockchain node generates blocks based on the state data stored in the second state database.

[0087] In an embodiment of the present application, the state data of the chain to be exchanged is added to the second blockchain by executing a transaction. After the data is added, the state data of the chain to be exchanged can be stored in the second state database of the second blockchain. This step is to enable the newly added nodes of the second blockchain to directly complete the data synchronization of the first blockchain by synchronizing the blocks on the chain, thereby facilitating block generation and improving processing efficiency.

[0088] The above process of executing a data chain-swap transaction based on the state data of the chain to be swapped and adding the state data of the chain to be swapped to the second blockchain can be achieved by the following methods:

[0089] (1) Generate a chain-swapping transaction block based on the status data of the chain to be swapped.

[0090] In the embodiment of the present application, the amount of chain status data to be replaced is generally large, so it is necessary to package the chain status data to be replaced in a block-generating manner, and then perform block consensus and chain operations based on the blocks of the chain status data to be replaced.

[0091] (2) Broadcast the chain swap transaction block to the consensus node of the first blockchain.

[0092] The information in the blockchain's genesis block must be unforgeable and tamper-proof to ensure the blockchain's security and reliability. Therefore, the accuracy and authenticity of transaction data must be verified. This involves broadcasting the chain swap transaction block to the consensus nodes of the first blockchain, which then return the consensus result. Consensus nodes can determine whether the execution node that broadcasted the transaction has the authority to execute transactions on the first blockchain, thereby determining the accuracy of the broadcasted chain swap transaction block.

[0093] The consensus result returned by each consensus node can be that the execution node has the authority to perform transaction operations on the blockchain, or that the execution node does not have the authority to perform transaction operations on the blockchain.

[0094] (3) If the consensus result of each consensus node on the chain swap transaction block is received and it is determined that the chain swap transaction block consensus is passed, the chain swap transaction block is added to the second blockchain.

[0095] After receiving the consensus results of each consensus node for the chain swap transaction block, the consensus results can be analyzed according to the consensus rules to determine whether the chain swap transaction block has passed the consensus.

[0096] In one embodiment, the consensus result is analyzed according to the consensus rules. Specifically, the number of consensus nodes corresponding to the consensus result that the execution node has the authority to execute transaction operations on the blockchain is detected, and then the ratio between this number and the total number of consensus nodes in the blockchain network is determined. If the ratio exceeds the target ratio, the consensus of the chain swap transaction block can be determined to have been passed. The target ratio can be pre-set. For example, if the number of consensus nodes in the blockchain network is N (N is greater than or equal to 2), the target ratio can be set to N / 2 or N*2 / 3 according to business conditions.

[0097] After the state data of the chain to be exchanged is added to the second blockchain, the state data of the chain to be exchanged can be stored in the second state database of the second blockchain, so that the blockchain node generates blocks based on the state data stored in the second state database. That is, when the second blockchain generates blocks, the block state data corresponding to the pending transaction is directly obtained from the second state database of the second blockchain, and the transaction block is generated, thereby improving efficiency.

[0098] The above process of storing the state data of the chain to be exchanged in the second state database of the second blockchain can be achieved by the following method:

[0099] In the second state database of the second blockchain, the state data of the chain to be exchanged is mapped and stored with the target smart contract.

[0100] Since in step S201, the state data of the chain to be swapped in the first state database of the first blockchain is obtained according to the target smart contract type, when the state data of the chain to be swapped is stored in the second state database of the second blockchain, the state data of the chain to be swapped can be stored based on the target smart contract type, that is, the state data of the chain to be swapped is stored in correspondence with the current target smart contract, ensuring that the state data after the chain swap is stored in the second blockchain in the same manner as that of the first blockchain, and ensuring that the state data after the chain swap is still in the same namespace as when it was stored in the first blockchain, which facilitates the writing of migration data.

[0101] This application constructs and implements a business smart contract in a blockchain smart contract, and the new chain business smart contract corresponds one-to-one with the original chain business smart contract. Taking the data migration from the original chain to the new chain as an example, the business smart contract can be divided into two life cycles, namely the migration life cycle and the business life cycle. During the migration life cycle, the business contract implements the function of writing the original chain status data to the new chain; during the business life cycle, the business logic of the original chain business smart contract is used to implement the status data writing function. During this cycle, the new chain business smart contract can execute business transactions normally. It can be understood that during the data migration process from the original chain to the new chain, the namespace of the original chain smart contract is used (that is, the new chain business smart contract corresponds one-to-one with the original chain business smart contract), which can make the original chain data migration more efficient and accurate.

[0102] In one embodiment, the following table shows the pseudocode of a business smart contract, which verifies whether the blockchain node creating the transaction has migration permissions, checks whether the state data transaction satisfies the multi-signature policy, and writes state data information in batches.

[0103]

[0104] The lifecycle of the aforementioned business smart contract is the entire blockchain lifecycle. After the migration is complete by calling the business smart contract, the putFabricWirteSet method can be disabled by upgrading the contract (for example, during migration, the migration business contract is used, and after the migration is complete, the migration business contract is upgraded to another business contract) and the corresponding business information is added. The contract permissions of the aforementioned business smart contract (specifically, the contract update policy) can be specified by the user. To ensure the security of the contract, it is recommended to adopt a global policy (i.e., the contract status can only be changed if all blockchain nodes agree).

[0105] See Figure 3 , Figure 3 A flowchart of a blockchain chain swap proposed in an embodiment of the present application is shown in the figure, which includes a server with two blockchains, namely the first blockchain and the second blockchain. The first blockchain includes a block body (including a genesis block, A1, A2, A3, An and other blocks) and a first state database, and the second blockchain includes a block body (including a genesis block, B1, B2, B3, Bn and other blocks), a second state database and an off-chain database. In the figure, the dotted arrows indicate the direction of data flow, that is, the data of the first state database can flow to the block body of the second blockchain, the data of the block body of the second blockchain can flow to the second state database, and the data of the block body of the first blockchain can flow to the off-chain database. Figure 3As shown in FIG, the process of chain switching is specifically as follows: the state data of the chain to be switched in the first state database of the first blockchain is added to the block body of the second blockchain (in addition, the anchor data to be uploaded generated according to the identification information of the target transaction data can also be added to the block body of the second blockchain); then the state data after chain switching is obtained from the block body of the second blockchain and stored in the second state database; and then the transaction data in the block body of the first blockchain is stored in the off-chain database of the second blockchain, thereby completing the chain switching process from the first blockchain to the second blockchain.

[0106] In one embodiment, a chain swap tool can be constructed, which includes a chain swap model and a blockchain development toolkit (e.g. Figure 4 The chain-changing model includes a data migration method for state data by executing transactions. The data migration method can be either a piece of executable code or a combination of multiple functional modules. Figure 4 , Figure 4 This is a schematic block diagram of a blockchain-based data migration method proposed in an embodiment of the present application. In the figure, the first blockchain takes the fabirc blockchain as an example, and the second blockchain takes the Chang'an Chain as an example. The business smart contract used in the data migration process is the migration business contract.

[0107] The implementation method of the data migration method includes the following steps:

[0108] (1) The chain-swapping tool reads the status data of the block to be processed in the status database file according to the fabirc blockchain node.

[0109] (2) The chain-swapping tool parses the pending block and stores the transaction data and block information (that is, the fabric transactions and blocks described in the figure) included in the pending block in an off-chain database (e.g., a MongoDB database).

[0110] (3) The chain-swapping tool iterates the state data of the fabric blockchain, and calls the migration business contract to execute the data chain-swapping transaction (that is, the transaction is on-chain) according to the namespace of the smart contract of the state data. The specific method is that the state data of the same namespace use the same migration business contract, and the transmission parameter of the execution contract is the fabric state data. The namespace of the new chain business smart contract called is consistent with the namespace of the original chain business smart contract.

[0111] In addition, the chain-swapping tool will also generate the anchor data to be uploaded to the chain and the state data migration transaction data based on the state data of the chain to be swapped. The role of the state data migration transaction data can be understood as the data chain-swapping transaction is executed based on the state data migration transaction data.

[0112] See Figure 5 , Figure 5 This is a timing diagram of a blockchain-based data migration method proposed in an embodiment of the present application. The timing diagram includes four main bodies, namely off-chain storage, fabric chain, chain switching tool and Changan Chain. The objects included in the off-chain storage are off-chain databases (MongoDB), the objects included in the fabric chain are fabric database files, the objects included in the chain switching tool are chain switching modules and blockchain development kits (SDKs), and the objects included in the Changan Chain are business smart contracts and anchor smart contracts. The implementation method of fabric state data migration includes the following steps:

[0113] (1) Open the fabric state database.

[0114] In the embodiment of the present application, the chain state data to be swapped in the fabric is obtained by iterating the fabric state data. Specifically, the chain swap model is first called to iterate the fabric state data from the fabric database file. The chain swap model then checks whether the fabric block height is consistent with the migration height, and exits if they are inconsistent. This step is to align the position of the block to which the migration data belongs in the original chain with the position of the block to which it belongs in the blockchain of the migration chain, thereby ensuring the security of the migration data. The chain swap model then constructs the state data chain swap transaction based on the fabric state data.

[0115] It should be noted that when the above chain-swapping model constructs a state data chain-swapping transaction based on state data, each state data chain-swapping transaction constructed by the state data belongs to the same business smart contract of the fabric chain, and the namespace of the business smart contract called in the Chang'an chain also needs to be consistent with the namespace of the business smart contract in the fabric chain.

[0116] (2) Execute fabric state data transactions.

[0117] In the embodiment of the present application, the chain exchange model calls the corresponding contract execution status data from the business smart contract to exchange the corresponding transaction of the chain exchange, and adds the status data to the Chang'an Chain.

[0118] (3) Open the fabric block file system.

[0119] In the embodiment of the present application, the chain-swapping model first reads the block data of the fabric chain; the chain-swapping model then parses the transaction data in the block data and constructs the anchor data corresponding to the transaction data; the chain-swapping model then calls the anchor smart contract from the Chang'an chain and adds the anchor data to the Chang'an chain.

[0120] (4) Off-chain storage of fabric transactions and blocks.

[0121] In the embodiment of the present application, the chain exchange model stores transaction data and block information in the off-chain database MongoDB, so that the blockchain node can query transaction data from the off-chain database based on the anchor data on the Changan chain.

[0122] S203. Execute a data on-chain transaction based on the anchored data to be on-chain, add the anchored data to be on-chain to the second blockchain, and store the target transaction data and block information contained in the block to be processed in an off-chain database, so that the blockchain node queries the target transaction data from the off-chain database based on the anchored data on the second blockchain.

[0123] In the embodiment of the present application, the anchored data to be uploaded to the chain refers to the data used to help verify whether the target transaction data belongs to the original chain transaction. The anchored data needs to be stored on the migration target chain and has the characteristic of being tamper-proof. Therefore, the user can verify the validity and integrity of the off-chain stored data based on the information such as txHash (i.e., transaction hash) and txStatus (i.e., transaction valid status value) included in the anchored data to be uploaded to the chain.

[0124] This application implements the on-chain operation of adding anchored data to a secondary blockchain by executing a transaction. This process utilizes an anchoring smart contract. This application constructs and implements an anchoring smart contract within a blockchain smart contract. This anchoring smart contract supports data storage and querying of the anchored data of transactions on the original chain (i.e., the aforementioned anchored data to be on-chain). This facilitates user verification of the existence, integrity, and validity of off-chain stored data at a later stage.

[0125] In one embodiment, the table below shows the pseudocode of the anchor smart contract. The function of its putAnchorData method is to support the query of fabric original chain transaction data through anchor data; the function of its AnchorData method is to verify whether the blockchain node creating the transaction has migration permission, check whether the state data transaction can meet the multi-signature ratio, and write anchor data information in batches.

[0126]

[0127] The lifecycle of the aforementioned anchored smart contract is the entire blockchain lifecycle. After calling the anchored smart contract to upload the anchored data, the putFabricWirteSet method can be disabled by upgrading the contract. The contract permissions (specifically, the contract update policy) of the aforementioned anchored smart contract can be specified by the user. To ensure contract security, a global policy is recommended for contract updates (i.e., changes to the contract state require the consent of all blockchain nodes).

[0128] The present application is to migrate the state data of the chain to be replaced of the first blockchain to the second blockchain by executing a transaction, that is, to execute a data chain exchange transaction based on the state data of the chain to be replaced and add the state data of the chain to be replaced to the second blockchain to complete the chain exchange, so that after the migration is completed, the newly added nodes of the second blockchain can directly synchronize the state data of the original chain in the same way as the blocks on the chain, without having to synchronize through the blocks of the original chain, thereby improving the efficiency of chain exchange; after adding the state data of the chain to be replaced to the second blockchain, the state data of the chain to be replaced and the block information are also stored in the second state database of the second blockchain, thereby reducing the storage burden of the migration data on the second blockchain, and by generating the anchor data to be chained of the first blockchain, it is chained to the second blockchain, and then the state data in the second state database is verified according to the anchor data after chaining, thereby ensuring the data verifiability when the data is stored off-chain, improving the credibility of the off-chain stored data, and ensuring the security of the data during the chain exchange process. When generating blocks, blockchain nodes can directly obtain data from the state data stored in the second state database, thereby improving the efficiency of block generation. At the same time, this application obtains the state data of the chain to be exchanged from the first state database based on the type of smart contract, and corresponds to the type of the above-mentioned smart contract, and maps the state data of the chain to be exchanged with the target smart contract in the second state database for smart contract storage, thereby ensuring the state consistency of the original chain state data in the second blockchain; by implementing business smart contracts, where the business smart contracts need to correspond to the original chain business contracts, the data migration of the original chain is more efficient and accurate; by implementing anchored smart contracts, the function of transaction query of the original chain transaction data through anchored data is realized.

[0129] See Figure 6 , Figure 6 This is a flow chart of another data processing method based on blockchain provided by an embodiment of the present application. The data processing method of the embodiment of the present application is mainly described from the perspective of the blockchain node. Figure 6 As shown, the blockchain-based data processing method may include:

[0130] S601. In response to a transaction data query request for a second blockchain, query transaction data stored on the second blockchain based on a query identifier carried in the transaction data query request.

[0131] In the embodiments of this application, the processing target is the second blockchain, which is obtained by performing a chain swap on the first blockchain in the aforementioned embodiments using the chain swap method proposed in this application. First, a transaction data query request is obtained from the blockchain node. The transaction data query request carries a query identifier (e.g., a transaction identifier). The transaction data stored on the second blockchain (i.e., the on-chain data migrated from the first blockchain to the second blockchain after the chain swap operation) is then checked to see whether there is transaction data corresponding to the query identifier carried in the query request. The reason for performing the on-chain data query first is that, in the transaction query scenario after the migration is complete, the frequency of querying transactions on the first blockchain (i.e., the fabric chain) is much lower than that of querying transactions on the new chain. Therefore, when performing a transaction query, it is possible to first perform an on-chain query on the second blockchain, reducing the complexity of subsequent transaction queries on the second blockchain.

[0132] Performing an on-chain query on the second blockchain can include two scenarios: the first is finding the transaction data stored on the chain, and the second is not finding the transaction data stored on the chain. In the first scenario, if the second blockchain stores the requested transaction data, it can be determined that the requested transaction data exists, and subsequent operations can be performed based on the retrieved transaction data. In the second scenario, if the requested transaction data is not found on the second blockchain, it means that the transaction data may be stored in an off-chain database of the second blockchain, or the transaction data itself may not exist. Therefore, the existence of the data can be verified based on the method provided in the subsequent step S602.

[0133] See Figure 7 , Figure 7 This is a schematic diagram of a transaction query method based on blockchain proposed in an embodiment of the present application. The query tool includes a blockchain development toolkit (e.g. Figure 7 The ChainMakersDK query tool (in the example) can be a service that uses ChainMakersDK or a module that encapsulates ChainMakersDK. This query tool helps route Fabric chain transactions to off-chain queries and verify whether the original chain transaction data stored off-chain is consistent with the transaction hash recorded in the anchor data. If the transaction hash is consistent, it proves that the off-chain transaction has not been tampered with. In the figure, the first blockchain uses the Fabric blockchain as an example, and the second blockchain uses the Chang'an Chain as an example. The smart contracts used in the transaction query process are business smart contracts and anchor smart contracts.

[0134] The implementation method of querying target transaction data includes the following steps:

[0135] (1) In the Changan Chain node (i.e., the chainmaker node), the target transaction data is queried in the transaction data stored on the second blockchain by calling the business smart contract.

[0136] (2) If the target transaction data is not found in the transaction data stored on the second blockchain, the anchor data corresponding to the target transaction data is queried in the anchor data stored on the second blockchain by calling the anchor smart contract in the Changan Chain node.

[0137] (3) If the anchor data corresponding to the target transaction data is found in the anchor data stored on the second blockchain, the query transaction data of the target transaction data is queried from the off-chain database (e.g., MongoDB database) based on the anchor data corresponding to the target transaction data.

[0138] See Figure 8 , Figure 8 This is a timing diagram of a blockchain-based transaction query method proposed in an embodiment of the present application. The timing diagram includes three main bodies, namely off-chain storage, query tools, and Changan Chain. The objects included in the off-chain storage are off-chain databases, the objects included in the query tool are users (clients) and the Changan Chain development toolkit (chainmakersdk), and the objects included in the Changan Chain are business smart contracts and anchored smart contracts. The implementation method of transaction query includes the following steps:

[0139] (1) Query transactions on the chain.

[0140] The user uses the blockchain development toolkit (such as chainmakersdk in the figure) to call the business smart contract in the Changan Chain to query the on-chain transactions; then the query result is returned to the user; if the query result shows that the transaction exists, it returns (that is, exits the transaction query process); if the query result shows that the transaction does not exist, execute the following step (2).

[0141] (2) Query the transaction anchor information from the anchor contract.

[0142] The user uses the blockchain development toolkit to call the anchor smart contract in the Changan Chain to query the anchor information of the transaction from the anchor contract; then the query result is returned to the user; if the query result shows that the anchor information of the transaction does not exist, it is determined that the transaction does not exist; if the query result shows that the anchor information of the transaction exists, the following step (3) is executed.

[0143] (3) Query transactions outside the chain.

[0144] The user queries the query transaction data corresponding to the anchor information of the transaction from the off-chain database; then verifies the integrity of the transaction.

[0145] The specific implementation method of the above query target transaction data can be found in the relevant description of steps S601 to S603.

[0146] S602. If the query transaction data corresponding to the query identifier is not found, query the anchor data stored on the second blockchain based on the query identifier; wherein the anchor data is generated based on the identification information of the target transaction data, the target transaction data is included in the block to be processed, and the block to be processed is a block on the first blockchain; the anchor data stored on the second blockchain is added to the second blockchain when a data on-chain transaction is executed based on the anchor data corresponding to the first blockchain in response to the chain switching operation.

[0147] In this embodiment of the present application, the second blockchain is obtained by performing a chain swap on the pending blocks and the pending chain swap state data of the first blockchain. That is, the first blockchain is the original blockchain, and the second blockchain is the new blockchain. In response to the chain swap operation, data from the original blockchain can be migrated to the second blockchain by executing a transaction. During the chain swap operation, anchor data is added to the second blockchain. The data migration in response to the chain swap operation is described in the previous embodiment and will not be further elaborated in this embodiment of the present application.

[0148] In one embodiment, the anchor data to be uploaded to the first blockchain can be generated based on the identification information of the target transaction data. The anchor data to be uploaded to the first blockchain includes the data required for the upload operation. The format of the anchor data to be uploaded to the first blockchain can be as described in step S201 of the aforementioned embodiment, and will not be further described in this embodiment.

[0149] Since the anchor data includes the data required for on-chain operations, such as the original chain transaction identifier, the hash value of the original chain's off-chain storage data, the valid status value of the transaction data, the height of the block to which the transaction belongs, the order of the transaction in the block, etc., it is possible to query whether there is transaction data corresponding to the query identifier in the anchor data. For example, when the transaction identifier of the transaction data to be queried is a, if the transaction data with the transaction identifier a is not queried on the second blockchain, it is possible to query whether there is anchor data with the transaction identifier a in the anchor data of the second blockchain.

[0150] Querying the anchored data of the second blockchain for transaction data corresponding to the query identifier can include two situations: the first is that the anchored data corresponding to the query identifier is found, and the second is that the anchored data corresponding to the query identifier is not found. In the first situation, the identification information of the transaction data to be queried is present in the anchored data of the second blockchain, and the query transaction data of the transaction data can be obtained based on the method provided in the subsequent step S603. In the second situation, the identification information of the transaction data to be queried is not present in the anchored data of the second blockchain, indicating that the transaction data is neither on the second blockchain nor in an off-chain database of the second blockchain, and it can be determined that the queried transaction data does not exist.

[0151] S603. If the anchor data corresponding to the query identifier is found, query the query transaction data corresponding to the query identifier from the off-chain database based on the query identifier; wherein the off-chain database stores the target transaction data and block information included in the block to be processed, and the target transaction data and block information are added to the off-chain database in response to the chain switching operation.

[0152] In the embodiments of this application, anchor data refers to data used to verify whether the target transaction data belongs to the original chain transaction. Anchor data needs to be stored on the migration target chain and is tamper-proof. Therefore, the anchor data, including information such as txHash (transaction hash) and txStatus (transaction validity status), can help users verify the validity and integrity of off-chain stored data. The specific implementation of adding the target transaction data and block information to the off-chain database in response to the chain switch operation is described in the previous embodiments and will not be repeated in this embodiment.

[0153] This application implements the on-chain operation of adding anchored data to a secondary blockchain by executing a transaction. This process utilizes an anchoring smart contract. This application constructs and implements an anchoring smart contract within a blockchain smart contract. This anchoring smart contract supports data storage and querying of the anchored data of transactions on the original blockchain (i.e., the aforementioned anchored data to be on-chain). This helps users later verify the existence, integrity, and validity of off-chain stored data. For details on the implementation of the anchoring smart contract, please refer to the method provided in the previous embodiment and will not be further elaborated in this embodiment.

[0154] The above step S603 may include two situations. The first situation is that the above query transaction data can be queried in the off-chain database; the second situation is that the above query transaction data cannot be queried in the off-chain database.

[0155] When the first situation mentioned above occurs, you can implement it by the following methods:

[0156] (1) If the query transaction data corresponding to the query identifier is found from the off-chain database, the first hash value of the query transaction data is calculated.

[0157] (2) Obtain the second hash value of the recorded query transaction data from the anchor data corresponding to the query identifier.

[0158] (3) If the first hash value is consistent with the second hash value, a first verification result is obtained, and the first verification result is used to indicate that the query transaction data stored in the off-chain database has not been tampered with.

[0159] (4) If the first hash value is inconsistent with the second hash value, a second verification result is obtained, and the second verification result is used to indicate that the query transaction data stored in the off-chain database has been tampered with.

[0160] Because the query transaction data corresponding to the query identifier queried from the off-chain database itself cannot determine the validity of the data, for example, after the data is tampered with, the tampered data is stored in the off-chain database. At this time, using this data for subsequent block generation will pose a great risk. Before and after the data is tampered with, the hash value of the data will change. When the anchor data is uploaded to the chain, the hash value of the real data will be stored (that is, the second hash value). Through the queried transaction data, the hash value of the corresponding data (that is, the first hash value) can be obtained. By comparing the first hash value with the second hash value, the changes in the query transaction data stored in the off-chain database can be analyzed, thereby verifying the query transaction data and ensuring the validity of the data. By comparing the first hash value and the second hash value, the following two results can be obtained (that is, the two results corresponding to (1) and (2) in the above step S603). The first result is that the first hash value and the second hash value are consistent, and the second result is that the first hash value and the second hash value are inconsistent.

[0161] Under the first result, the following operations can also be performed: If the first verification result is obtained, relevant operations are performed based on the query transaction data queried from the off-chain database.

[0162] Once the first verification result is obtained, indicating that the query transaction data stored in the off-chain database has not been tampered with, operations such as block generation and data analysis can be performed based on the obtained query transaction data. In one embodiment, when a blockchain node queries all broadcast transaction data and verifies that all broadcast transaction data has not been tampered with, a consensus can be reached on the broadcast, allowing the node executing the broadcast to proceed with subsequent operations. In another embodiment, if a user has questions about a previous transaction and needs to query transaction information, if it is determined that the query transaction data has not been tampered with, data analysis can be performed based on the verified transaction data to obtain more authentic transaction data information.

[0163] Under the second result, the following operations may also be performed: if the second verification result is obtained, a tampering mark is added to the query transaction data in the off-chain database.

[0164] A tampering mark is added to the query transaction data stored in the off-chain database that has been tampered with. When the transaction data is subsequently queried for the second time, it can be directly queried whether the transaction data has the tampering mark, omitting the calculation and judgment of the hash value. If the transaction data is found to have the tampering mark, it is determined that the transaction data has been tampered with, thereby improving the query efficiency.

[0165] By combining the methods provided in steps S201-S203 and S601-S603 of this application, the state data of the chain to be exchanged of the first blockchain can be migrated to the second blockchain, and the state data of the chain to be exchanged of the first blockchain can be stored in the second state database corresponding to the second blockchain. Anchor data can be generated to verify the stored state data of the chain to be exchanged, thereby improving the credibility of the data. After the first blockchain is exchanged based on the above method and the second blockchain is obtained, the second blockchain can be used to process new transactions, thereby achieving the purpose of replacing the first blockchain for business processing by the second blockchain.

[0166] Using the second blockchain for block generation can be achieved through the following methods:

[0167] (1) Determine the block transaction data of the transaction to be processed.

[0168] In an embodiment of the present application, first, multiple transactions in the pending transaction are generated into block transaction data. For example, in a payment scenario, including account A and account B, the current account balance of account A is 300 yuan, and the account balance of account B is 100 yuan. The transaction between account A and account B includes account A transferring 50 yuan to account B, then the block transaction data includes: account A transfers 50 yuan to account B.

[0169] In one embodiment, when the number of transactions to be processed is large, a block generation size can be preset, and the transaction data to be processed can be divided into blocks according to the block generation size to obtain multiple blocks of transaction data. Subsequently, the multiple blocks of transaction data can be processed separately according to preset rules (for example, processing according to the block division order) to achieve the purpose of generating multiple blocks.

[0170] (2) Obtain the initial state data corresponding to the pending transaction from the second state database.

[0171] In the embodiment of the present application, the second state database stores the initial state data under the current state, which can be understood as the current state value of each node. Based on the scenario provided above, the initial state data includes: the balance of account A is 300 yuan; the balance of account B is 100 yuan.

[0172] (3) Determine the block status data corresponding to the pending transaction based on the block transaction data and initial status data.

[0173] In this embodiment of the present application, block state data is obtained by updating the initial state data based on block transaction data. Based on the scenario provided above, account A transfers 50 yuan to account B. Account A's initial balance is 300 yuan; account B's initial balance is 100 yuan. Then, the state data update process for account A is 300-50 = 250 yuan; the state data update process for account B is 100+50 = 150 yuan. The final block state data includes: Account A's balance is 250 yuan; Account B's balance is 150 yuan.

[0174] In one embodiment, in order to facilitate the acquisition of updated state data, the following method may be used: the initial state data in the second state database may be updated based on the block state data, and the updated state data may be stored in the second state database.

[0175] (4) Generate transaction blocks for pending transactions based on block transaction data and block status data.

[0176] A transaction block consists of transaction data, state data, and block information (e.g., various data in a block header) in the current state. Therefore, after the initial state data in the second-state database is updated, a transaction block is constructed using the block transaction data and block state data (wherein, the block transaction data and block state data include data for constructing the block information in the transaction block).

[0177] In the embodiments of this application, the second blockchain needs to be described. The second blockchain is the target blockchain for the chain swap operation. Specifically, the chain swap operation involves swapping the state data in the first blockchain to the second blockchain. The method for swapping the first blockchain to the second blockchain includes the following steps.

[0178] (1) In response to the chain switching operation, the state data of the chain to be switched is obtained from the first state database of the first blockchain.

[0179] (2) Execute a data chain exchange transaction based on the state data of the chain to be exchanged, and add the state data of the chain to be exchanged to the second blockchain.

[0180] (3) After adding the state data of the chain to be exchanged to the second blockchain, the state data of the chain to be exchanged is stored in the second state database of the second blockchain; wherein the state data stored in the second state database is used for block generation.

[0181] The specific implementation of the above steps (1) to (3) can be found in S201 to S202 in the above embodiment, and will not be described in detail in this application.

[0182] In one embodiment, when switching from a first blockchain to a second blockchain, transaction data and block information can be stored in an off-chain database. This allows blockchain nodes to directly retrieve data from the state data stored in the second state database when generating blocks, improving block generation efficiency. To ensure data verifiability during off-chain storage and safeguard data security during the chain switching process, this application generates anchor data corresponding to the first blockchain and stores it in the second blockchain, thereby enabling verification of the state data in the second state database using the anchor data. The method for switching from a first blockchain to a second blockchain includes the following steps.

[0183] (1) Obtain the anchor data corresponding to the first blockchain.

[0184] (2) Execute a data on-chain transaction based on the anchor data corresponding to the first blockchain, and add the anchor data corresponding to the first blockchain to the second blockchain.

[0185] The specific implementation of steps (1) to (2) above can be found in S201 to S202 in the aforementioned embodiment, and this application will not elaborate on them here. In addition, it should be noted that the execution subject of steps S601 to S603 can be the same as or different from the execution subject of steps S201 to S203.

[0186] The present application proposes a transaction query method, which first queries the transaction data stored on the second blockchain chain for transaction data, so as to improve the query speed of the initial query and reduce the complexity of the subsequent query on the second blockchain; if the transaction data is not queried in the on-chain stored data, then query whether there is corresponding transaction data in the anchor data stored on the second blockchain chain; if the transaction data is queried in the anchor data, then query the transaction data in the off-chain data; if the transaction data is not queried in the anchor data, then determine that the transaction data does not exist. The above method improves the accuracy and efficiency of transaction query; in the case where the transaction data is queried in the off-chain data, it is also determined by Compare the hash value of the queried transaction data with the hash value of the transaction data stored in the anchor data to determine whether the transaction data stored outside the chain has been changed. If changed, mark it, thereby improving the efficiency of subsequent queries to the transaction data; the application also provides a method for block generation using a second blockchain, updating the block status data of the second blockchain according to the block transaction data of the transaction to be processed, and updating the status data stored outside the second blockchain chain, so that the newly added node can obtain the updated status data, improve the efficiency of block generation, and generate a new transaction block according to the block transaction data and the updated block status data, and efficiently complete the block generation.

[0187] See also Figure 9, is a schematic diagram of the structure of a blockchain-based data processing device provided in an embodiment of the present application. The data processing device described in this embodiment can be applied to the first embodiment described above, including:

[0188] Data migration module 901 is configured to, in response to a chain swap operation, obtain the chain swap state data to be swapped from the first state database of the first blockchain, and obtain the anchor data to be uploaded to the chain of the first blockchain; wherein the anchor data to be uploaded to the chain is generated based on the identification information of the target transaction data, the target transaction data is included in the block to be processed, and the block to be processed is a block on the first blockchain;

[0189] The data migration module 901 is further configured to execute a data chain-swap transaction based on the chain-to-be-swapped state data, add the chain-to-be-swapped state data to the second blockchain, and, after adding the chain-to-be-swapped state data to the second blockchain, store the chain-to-be-swapped state data in a second state database of the second blockchain, so that the blockchain node generates blocks based on the state data stored in the second state database.

[0190] The above-mentioned data migration module 901 is also used to perform data on-chain transactions based on the above-mentioned anchored data to be on-chain, add the above-mentioned anchored data to be on-chain to the above-mentioned second blockchain, and store the above-mentioned target transaction data and block information contained in the above-mentioned block to be processed in an off-chain database, so that the blockchain node can query the above-mentioned target transaction data from the above-mentioned off-chain database based on the anchored data on the above-mentioned second blockchain.

[0191] Optionally, when the data migration module 901 is used to obtain the state data of the chain to be swapped from the first state database of the first blockchain, it is specifically used to:

[0192] Obtain the to-be-swapped chain state data corresponding to the target smart contract from the first state database of the first blockchain.

[0193] When the data migration module 901 is used to store the state data of the to-be-swapped chain in the second state database of the second blockchain, it is specifically used to:

[0194] In the second state database of the second blockchain, the state data of the chain to be exchanged is mapped and stored with the target smart contract.

[0195] Optionally, when the data migration module 901 is used to perform a data chain-swap transaction based on the chain-swap state data and add the chain-swap state data to the second blockchain, it is specifically used to:

[0196] Generate a chain swap transaction block based on the aforementioned chain swap status data;

[0197] Broadcasting the chain swap transaction block to the consensus node of the first blockchain;

[0198] If it is determined that the consensus of the chain-swap transaction block is passed based on the consensus results of the consensus nodes received for the chain-swap transaction block, the chain-swap transaction block is added to the second blockchain.

[0199] The data processing device described in this embodiment can be applied to the second embodiment described above, including:

[0200] A data query module 902 is configured to respond to a transaction data query request for a second blockchain and query the transaction data stored on the second blockchain based on a query identifier carried in the transaction data query request;

[0201] The data query module 902 is further used to:

[0202] If the query transaction data corresponding to the query identifier is not found, the anchor data stored on the second blockchain is queried based on the query identifier; wherein the anchor data is generated based on the identification information of the target transaction data, the target transaction data is included in the block to be processed, and the block to be processed is a block on the first blockchain; the anchor data stored on the second blockchain is added to the second blockchain when a data on-chain transaction is executed based on the anchor data corresponding to the first blockchain in response to the chain switching operation;

[0203] The data query module 902 is further used to:

[0204] If the anchor data corresponding to the query identifier is queried, the query transaction data corresponding to the query identifier is queried from the off-chain database based on the query identifier; wherein the off-chain database stores the target transaction data and block information contained in the block to be processed, and the target transaction data and block information are added to the off-chain database in response to the chain switching operation.

[0205] Optionally, the data query module 902 is further configured to:

[0206] If the query transaction data corresponding to the query identifier is found in the off-chain database, a first hash value of the query transaction data is calculated;

[0207] Obtaining a second hash value of the recorded query transaction data from the anchor data corresponding to the query identifier;

[0208] If the first hash value is consistent with the second hash value, a first verification result is obtained, and the first verification result is used to indicate that the query transaction data stored in the off-chain database has not been tampered with;

[0209] If the first hash value is inconsistent with the second hash value, a second verification result is obtained, and the second verification result is used to indicate that the query transaction data stored in the off-chain database has been tampered with.

[0210] Optionally, the data query module 902 is further configured to:

[0211] If the first verification result is obtained, then relevant operations are performed based on the query transaction data retrieved from the off-chain database;

[0212] If the second verification result is obtained, a tampering mark is added to the query transaction data in the off-chain database.

[0213] Optionally, the data query module 902 is further configured to:

[0214] In response to the chain-switching operation, obtaining the to-be-switched chain state data from the first state database of the first blockchain;

[0215] Execute a data chain-for-chain transaction based on the chain-for-chain state data, and add the chain-for-chain state data to the second blockchain;

[0216] After adding the to-be-exchanged chain state data to the second blockchain, the to-be-exchanged chain state data is stored in a second state database of the second blockchain; wherein the state data stored in the second state database is used for block generation.

[0217] Optionally, the data query module 902 is further configured to:

[0218] Obtaining anchor data corresponding to the first blockchain;

[0219] A data on-chain transaction is performed based on the anchor data corresponding to the first blockchain, and the anchor data corresponding to the first blockchain is added to the second blockchain.

[0220] It should be noted that the functions of each functional module of the data processing device of the embodiment of the present application can be specifically implemented according to the method in the above method embodiment. The specific implementation process can refer to the relevant description of the above method embodiment, which will not be repeated here.

[0221] See also Figure 10 , is a schematic diagram of the structure of a data processing device provided in an embodiment of the present application. The data processing device described in this embodiment includes: a processor 1001, a memory 1002, and a network interface 1003. The processor 1001, the memory 1002, and the network interface 1003 can exchange data.

[0222] The processor 1001 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor may be a microprocessor or any conventional processor.

[0223] The memory 1002 may include a read-only memory and a random access memory, and provides program instructions and data to the processor 1001. A portion of the memory 1002 may also include a non-volatile random access memory. In a feasible embodiment, the data processing device may be applied to the first embodiment described above, wherein the processor 1001 is configured to execute the following when calling the program instructions:

[0224] In response to the chain-swap operation, obtaining the chain-swap state data to be exchanged and the anchor data to be uploaded to the chain of the first blockchain from the first state database of the first blockchain; wherein the anchor data to be uploaded to the chain is generated based on the identification information of the target transaction data, the target transaction data is included in the block to be processed, and the block to be processed is a block on the first blockchain;

[0225] executing a data chain-for-chain transaction based on the chain-for-chain state data, adding the chain-for-chain state data to the second blockchain, and, after adding the chain-for-chain state data to the second blockchain, storing the chain-for-chain state data in a second state database of the second blockchain, so that the blockchain node generates blocks based on the state data stored in the second state database;

[0226] Execute data on-chain transactions based on the anchored data to be on-chain, add the anchored data to be on-chain to the second blockchain, and store the target transaction data and block information contained in the block to be processed in an off-chain database, so that the blockchain node can query the target transaction data from the off-chain database based on the anchored data on the second blockchain.

[0227] Optionally, when the processor 1001 is used to obtain the state data of the chain to be swapped from the first state database of the first blockchain, it is specifically used to:

[0228] Obtain the to-be-swapped chain state data corresponding to the target smart contract from the first state database of the first blockchain.

[0229] When the processor 1001 is used to store the state data of the to-be-swapped chain in the second state database of the second blockchain, it is specifically used to:

[0230] In the second state database of the second blockchain, the state data of the chain to be exchanged is mapped and stored with the target smart contract.

[0231] Optionally, when the processor 1001 is configured to execute a data chain-swap transaction based on the to-be-swapped chain state data and add the to-be-swapped chain state data to the second blockchain, it is specifically configured to:

[0232] Generate a chain swap transaction block based on the aforementioned chain swap status data;

[0233] Broadcasting the chain swap transaction block to the consensus node of the first blockchain;

[0234] If it is determined that the consensus of the chain-swap transaction block is passed based on the consensus results of the consensus nodes received for the chain-swap transaction block, the chain-swap transaction block is added to the second blockchain.

[0235] In a feasible embodiment, the data processing device may be applied to the second embodiment described above, wherein the processor 1001 is configured to execute the following when calling the program instructions:

[0236] In response to a transaction data query request for a second blockchain, querying the transaction data stored on the second blockchain based on a query identifier carried in the transaction data query request;

[0237] If the query transaction data corresponding to the query identifier is not found, the anchor data stored on the second blockchain is queried based on the query identifier; wherein the anchor data is generated based on the identification information of the target transaction data, the target transaction data is included in the block to be processed, and the block to be processed is a block on the first blockchain; the anchor data stored on the second blockchain is added to the second blockchain when a data on-chain transaction is executed based on the anchor data corresponding to the first blockchain in response to the chain switching operation;

[0238] If the anchor data corresponding to the query identifier is queried, the query transaction data corresponding to the query identifier is queried from the off-chain database based on the query identifier; wherein the off-chain database stores the target transaction data and block information contained in the block to be processed, and the target transaction data and block information are added to the off-chain database in response to the chain switching operation.

[0239] Optionally, the processor 1001 is further configured to:

[0240] If the query transaction data corresponding to the query identifier is found in the off-chain database, a first hash value of the query transaction data is calculated;

[0241] Obtaining a second hash value of the recorded query transaction data from the anchor data corresponding to the query identifier;

[0242] If the first hash value is consistent with the second hash value, a first verification result is obtained, where the first verification result is used to indicate that the query transaction data stored in the off-chain database has not been tampered with;

[0243] If the first hash value is inconsistent with the second hash value, a second verification result is obtained, and the second verification result is used to indicate that the query transaction data stored in the off-chain database has been tampered with.

[0244] Optionally, the processor 1001 is further configured to:

[0245] If the first verification result is obtained, performing relevant operations based on the query transaction data retrieved from the off-chain database;

[0246] If the second verification result is obtained, a tampering mark is added to the query transaction data in the off-chain database.

[0247] Optionally, the processor 1001 is further configured to:

[0248] In response to the chain-switching operation, obtaining the to-be-switched chain state data from the first state database of the first blockchain;

[0249] Execute a data chain-for-chain transaction based on the chain-for-chain state data, and add the chain-for-chain state data to the second blockchain;

[0250] After adding the to-be-exchanged chain state data to the second blockchain, the to-be-exchanged chain state data is stored in a second state database of the second blockchain; wherein the state data stored in the second state database is used for block generation.

[0251] Optionally, the processor 1001 is further configured to:

[0252] Obtaining anchor data corresponding to the first blockchain;

[0253] A data on-chain transaction is performed based on the anchor data corresponding to the first blockchain, and the anchor data corresponding to the first blockchain is added to the second blockchain.

[0254] In a specific implementation, the processor 1001, the storage device 1002, and the network interface 1003 described in the embodiment of the present application can execute the embodiment of the present application. Figure 2 or Figure 6 The implementation described in the relevant embodiments of the data processing method provided can also be performed in the embodiments of this application Figure 9 The implementation methods described in the relevant embodiments of the provided data processing device will not be repeated here.

[0255] In the several embodiments provided in this application, it should be understood that the disclosed methods, devices, and systems can be implemented in other ways. For example, the device embodiments described above are merely schematic; for example, the division of the units is merely a logical function division, and there may be other division methods in actual implementation; for example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection of devices or units, which may be electrical, mechanical, or other forms.

[0256] The embodiment of the present application also provides a computer-readable storage medium, wherein the computer-readable storage medium stores program instructions, and when the program is executed, it may include the following: Figure 2 or Figure 6 Part or all of the steps of the blockchain-based data processing method in the corresponding embodiment.

[0257] It should be noted that for the aforementioned various method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this application.

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

[0259] The present application also provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a server reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the server to perform the steps performed in the above-described method embodiments.

[0260] The above is a detailed introduction to a blockchain-based data processing method, device, equipment, and medium provided in the embodiments of the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core ideas of the present application. At the same time, for those skilled in the art, according to the ideas of the present application, there may be changes in the specific implementation methods and application scopes. In summary, the contents of this specification should not be understood as limiting the present application.

Claims

1. A data processing method based on blockchain, characterized in that: The method comprises: In response to the chain-swap operation, obtaining the chain-swap state data to be exchanged from the first state database of the first blockchain, and obtaining the anchor data to be uploaded to the chain of the first blockchain; wherein the anchor data to be uploaded to the chain is generated based on the identification information of the target transaction data, the target transaction data is included in the block to be processed, and the block to be processed is a block on the first blockchain; executing a data chain-for-chain transaction based on the chain-for-chain state data, adding the chain-for-chain state data to a second blockchain, and, after adding the chain-for-chain state data to the second blockchain, storing the chain-for-chain state data in a second state database of the second blockchain, so that blockchain nodes generate blocks based on the state data stored in the second state database; Execute a data on-chain transaction based on the anchor data to be on-chain, add the anchor data to be on-chain to the second blockchain, and store the target transaction data and block information contained in the block to be processed in an off-chain database, so that the blockchain node queries the target transaction data from the off-chain database based on the anchor data on the second blockchain.

2. The method according to claim 1, characterized in that The obtaining the to-be-swapped chain state data from the first state database of the first blockchain includes: Obtain the to-be-swapped chain state data corresponding to the target smart contract from the first state database of the first blockchain; Storing the to-be-swapped chain state data in the second state database of the second blockchain includes: In the second state database of the second blockchain, the state data of the chain to be exchanged and the target smart contract are mapped and stored.

3. The method according to claim 1 or 2, characterized in that The performing of the data chain-for-chain transaction based on the chain-for-chain state data, and adding the chain-for-chain state data to the second blockchain, includes: Generate a chain-swap transaction block based on the chain-swap status data; Broadcasting the chain swap transaction block to the consensus node of the first blockchain; If it is determined that the chain swap transaction block consensus is passed based on the received consensus results of the consensus nodes for the chain swap transaction block, the chain swap transaction block is added to the second blockchain.

4. A data processing method based on blockchain, characterized in that: The method comprises: In response to a transaction data query request for a second blockchain, querying the transaction data stored on the second blockchain based on a query identifier carried in the transaction data query request; If the query transaction data corresponding to the query identifier is not found, querying the anchor data stored on the second blockchain based on the query identifier; wherein the anchor data is generated based on the identification information of the target transaction data, the target transaction data is included in the block to be processed, and the block to be processed is a block on the first blockchain; the anchor data stored on the second blockchain is added to the second blockchain when a data on-chain transaction is performed based on the anchor data corresponding to the first blockchain in response to the chain switching operation; If the anchor data corresponding to the query identifier is queried, the query transaction data corresponding to the query identifier is queried from the off-chain database based on the query identifier; wherein the off-chain database stores the target transaction data and block information contained in the block to be processed, and the target transaction data and the block information are added to the off-chain database in response to the chain switching operation.

5. The method according to claim 4, characterized in that The method further comprises: If the query transaction data corresponding to the query identifier is found in the off-chain database, a first hash value of the query transaction data is calculated; Obtaining a second hash value of the recorded query transaction data from the anchor data corresponding to the query identifier; If the first hash value is consistent with the second hash value, a first verification result is obtained, where the first verification result is used to indicate that the query transaction data stored in the off-chain database has not been tampered with; If the first hash value is inconsistent with the second hash value, a second verification result is obtained, and the second verification result is used to indicate that the query transaction data stored in the off-chain database has been tampered with.

6. The method according to claim 5, characterized in that The method further comprises: If the first verification result is obtained, performing relevant operations based on the query transaction data retrieved from the off-chain database; If the second verification result is obtained, a tampering mark is added to the query transaction data in the off-chain database.

7. A data processing device based on blockchain, characterized in that: The method comprises a module for implementing the data processing method based on blockchain as claimed in any one of claims 1 to 3, or a module for implementing the data processing method based on blockchain as claimed in any one of claims 4 to 6.

8. A data processing device, characterized in that: The method comprises a processor, a memory, and a network interface, wherein the processor, the memory, and the network interface are interconnected, wherein the memory is used to store a computer program, and the computer program includes program instructions. The processor is configured to call the program instructions to implement the blockchain-based data processing method according to any one of claims 1 to 3, or to implement the blockchain-based data processing method according to any one of claims 4 to 6.

9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which includes program instructions. When the program instructions are executed by a processor, a computer device having the processor implements the blockchain-based data processing method as described in any one of claims 1 to 3, or implements the blockchain-based data processing method as described in any one of claims 4 to 6.

10. A computer program product, characterized in that The computer program product includes a computer program or computer instructions. When the computer program or computer instructions are executed by a processor, the blockchain-based data processing method according to any one of claims 1 to 3 is implemented, or the blockchain-based data processing method according to any one of claims 4 to 6 is implemented.

Citation Information

Patent Citations

  • Data processing method and device based on block chain and related equipment

    CN113034137A

  • Blockchain–based data processing method, apparatus, device, and readable storage medium

    WO2021233049A1