CN115730935A - Data processing method, device and equipment based on block chain and readable storage medium - Google Patents

Data processing method, device and equipment based on block chain and readable storage medium Download PDF

Info

Publication number
CN115730935A
CN115730935A CN202111005785.8A CN202111005785A CN115730935A CN 115730935 A CN115730935 A CN 115730935A CN 202111005785 A CN202111005785 A CN 202111005785A CN 115730935 A CN115730935 A CN 115730935A
Authority
CN
China
Prior art keywords
transaction
stored
node
block
block information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111005785.8A
Other languages
Chinese (zh)
Inventor
邵珠光
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202111005785.8A priority Critical patent/CN115730935A/en
Publication of CN115730935A publication Critical patent/CN115730935A/en
Pending legal-status Critical Current

Links

Images

Abstract

The application discloses a data processing method, a device, equipment and a readable storage medium based on a block chain, wherein the method comprises the following steps: acquiring a transaction verification request sent by a first node in a first service chain; calling a transaction verification contract on the relay chain based on the transaction verification request, and acquiring a target index pair in the relay chain through the transaction verification contract and the information of the chain to be verified; the target index pair is generated when the transaction block information is stored by the data storage contract; the target index pair is used for indicating the mapping relation between a target index key and a target index value, and the target index key comprises a block storage parameter associated with transaction block information; and performing transaction verification on the transaction data to be verified based on the transaction identification of the transaction data to be verified and the transaction block information in the target index value, and sending a verification result to the first node. By adopting the method and the device, the reliability of the verification result can be improved in the cross-chain transaction service, and the safety of the cross-chain transaction service is further improved.

Description

Data processing method, device and equipment based on block chain and readable storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a data processing method, apparatus, device, and readable storage medium based on a block chain.
Background
With the rapid development of the block chain technology, many service systems currently employ the block chain to store the related service data. In general, different service systems may configure different blockchains, and data interaction between different blockchains is often required due to service requirements, and the data interaction between different blockchains is generally referred to as cross-chain transaction.
When cross-chain transactions are conducted in different blockchains, the validity and existence of the cross-chain transactions generally need to be verified. The existing verification method of cross-link transaction mainly comprises the following steps: a service party needing transaction Verification directly calls a Simplified transaction Verification (SPV) node (an SPV node is a node in a block chain, usually does not participate in consensus, and is only used as a service node for verifying a transaction), and the SPV node is called to execute a function of providing a transaction proof to the outside. However, since the SPV node operates as a stand-alone node, if the called SPV node fails or the called SPV node is a malicious node, then transaction verification is likely to fail, and further, the cross-link transaction cannot be completed smoothly. That is, the existing verification method of the cross-chain transaction causes the security and the reliability of the cross-chain transaction to be low.
Disclosure of Invention
The embodiment of the application provides a data processing method, a data processing device, data processing equipment and a readable storage medium based on a block chain, which can improve the reliability of a verification result in a cross-chain transaction service, and further improve the safety of the cross-chain transaction service.
An embodiment of the present application provides a data processing method based on a block chain, including:
acquiring a transaction verification request sent by a first node in a first service chain; the transaction verification request carries information of a chain to be verified and a transaction identifier of transaction data to be verified;
calling a transaction verification contract on the relay chain based on the transaction verification request, and acquiring a target index pair in the relay chain through the transaction verification contract and the information of the chain to be verified; the target index pair is generated when transaction block information is stored by the data storage contract, the transaction block information being sent by a second node in the second service chain; the target index pair is used for indicating the mapping relation between a target index key and a target index value, the target index key comprises a block storage parameter associated with transaction block information, and the block storage parameter is matched with the to-be-verified chain information; the target index value comprises transaction block information; the first service chain is different from the second service chain;
and performing transaction verification on the transaction data to be verified based on the transaction identification of the transaction data to be verified and the transaction block information in the target index value, and sending a verification result to the first node.
An embodiment of the present application provides a data processing apparatus based on a block chain, including:
the verification request acquisition module is used for acquiring a transaction verification request sent by a first node in a first service chain; the transaction verification request carries information of a chain to be verified and a transaction identifier of transaction data to be verified;
the index pair acquisition module is used for calling a transaction verification contract on the relay chain based on the transaction verification request;
the index pair acquisition module is also used for acquiring a target index pair in the relay chain through the transaction verification contract and the information of the chain to be verified; the target index pair is generated when transaction block information is stored by a data storage contract, the transaction block information being sent by a second node in the second business chain; the target index pair is used for indicating the mapping relation between a target index key and a target index value, the target index key comprises a block storage parameter associated with transaction block information, and the block storage parameter is matched with the to-be-verified chain information; the target index value comprises transaction block information; the first service chain is different from the second service chain;
the transaction verification module is used for performing transaction verification on the transaction data to be verified based on the transaction identification of the transaction data to be verified and the transaction block information in the target index value;
and the transaction verification module is also used for sending the verification result to the first node.
In one embodiment, the block chain based data processing apparatus further comprises:
the storage request acquisition module is used for acquiring a data storage request aiming at the transaction block information sent by the second node; the data storage request carries the block height of the block to which the transaction block information belongs;
the storage parameter determining module is used for calling a data storage contract in the relay chain according to the data storage request, and determining the chain identifier of the second service chain and the block height of the block to which the transaction block information belongs as block storage parameters through the storage logic of the data storage contract;
the key determining module is used for determining a target index key according to the block storage parameters;
the value determining module is used for determining a target index value according to the initial index value corresponding to the target index key, the transaction block information and the identifier of the second node;
and the data storage module is used for storing a target index pair consisting of the target index key and the target index value to the relay chain.
In one embodiment, the key determination module includes:
the index pair traversing unit is used for traversing N stored index pairs in the relay chain; a stored index pair for indicating a mapping between a stored index key and a stored index value; the stored index key comprises stored block storage parameters associated with the stored block information;
a key determination unit, configured to determine, if there is a target stored block storage parameter that is the same as the block storage parameter in the stored block storage parameters included in the N stored index pairs, a stored index key to which the target stored block storage parameter belongs as a target index key;
and the key determining unit is further used for determining an index key formed by the block storage parameters as a target index key if the target stored block storage parameters identical to the block storage parameters do not exist in the stored block storage parameters included in the N stored index pairs.
In one embodiment, the initial index value comprises M associative mapping relationships; the incidence mapping relation is used for indicating the incidence relation among stored serialized block information, a stored uploading node identification set corresponding to the stored serialized block information and the number of stored node identifications in the stored uploading node identification set; m is a positive integer;
the value determination module includes:
the serialization processing unit is used for carrying out serialization processing on the transaction block information to obtain target serialization block information;
the block information traversing unit is used for traversing the M pieces of serialized block information;
an index value determining unit, configured to, if there is target serialized block information that is the same as the target serialized block information in the M pieces of serialized block information, add a node identifier of the second node to a set of stored node identifiers corresponding to the target serialized block information, and increment the number of stored node identifiers in the set of stored node identifiers of the target set of stored node identifiers to obtain a target index value;
and the index value determining unit is further configured to, if there is no target serialized block information in the M pieces of serialized block information, generate a target upload node identifier set corresponding to the target serialized block information according to the node identifier of the second node, use the number of the node identifiers of the second node as the target node identifier number of the target upload node identifier set, and add the target serialized block information, the target upload node identifier set, and the target node identifier number to the initial index key in an associated manner to obtain a target index value.
In one embodiment, the value determination module further comprises:
the set traversing unit is used for traversing the uploaded node identification set corresponding to the target serialized block information;
the value determining unit is used for determining the initial index value as a target index value if the node identifier of the second node exists in the uploaded node identifier set corresponding to the target serialized block information;
and the step executing unit is used for adding the node identifier of the second node into the stored uploading node identifier set corresponding to the target stored serialized block information and increasing the number of the stored node identifiers of the target stored uploading node identifier set to obtain the target index value if the node identifier of the second node does not exist in the stored uploading node identifier set corresponding to the target stored serialized block information.
In one embodiment, the to-be-verified chain information includes a chain identifier of the second service chain and a block height of a block to which the to-be-verified transaction data belongs;
the index pair acquisition module comprises:
the traversing unit is used for traversing the N stored index pairs in the relay chain through the verification logic in the transaction verification contract; a stored index pair for indicating a mapping between a stored index key and a stored index value; the stored index key comprises stored block storage parameters associated with the stored block information; the stored index key comprises stored block storage parameters, and the stored block storage parameters comprise stored chain identification and stored block height; the stored chain identifier is a chain identifier of a stored service chain, the stored block height is the block height of the block to which the stored block information belongs, and the block to which the stored block information belongs to the stored service chain; the stored block information comprises transaction block information, the N stored index pairs comprise index pairs corresponding to the transaction block information, stored chain identification in the index pairs corresponding to the transaction block information is chain identification of the second service chain, stored block height in the index pairs corresponding to the transaction block information is block height of a block to which the transaction block information belongs, and the block height of the block to which the transaction block information belongs is the same as the block height of a block to which the transaction data to be verified belongs;
and the index pair determining unit is used for determining the index pair corresponding to the transaction block information, wherein the stored chain identification of the N stored index pairs is matched with the chain identification of the second service chain, and the stored block height is matched with the block height of the block to which the transaction data to be verified belongs, as the target index pair.
In one embodiment, the target index value includes Q associated mapping relationships; the incidence mapping relation is used for indicating the incidence relation among stored serialized block information, a stored uploading node identification set corresponding to the stored serialized block information and the number of stored node identifications in the stored uploading node identification set; one piece of stored serialized block information is information obtained after one piece of stored block information is serialized, and the Q pieces of stored serialized block information comprise target serialized block information corresponding to the transaction block information; q is a positive integer;
the transaction verification module includes:
the identification number comparison unit is used for acquiring the stored node identification number corresponding to the target serialized block information;
the identifier number comparing unit is further configured to take the largest stored node identifier number of the stored node identifier numbers respectively corresponding to the remaining stored serialized block information as the number of the node identifiers to be compared, and compare the number of the node identifiers to be compared with the number of the stored node identifiers corresponding to the target serialized block information; the remaining stored serialized block information is stored serialized block information except the target serialized block information in the Q stored serialized block information;
the target number determining unit is used for determining the stored node identification number corresponding to the target serialized block information and the maximum node identification number in the node identification numbers to be compared as the target node identification number;
and the transaction verification unit is used for performing transaction verification on the transaction data to be verified according to the number of the target node identifiers and the transaction identifier of the transaction data to be verified.
In an embodiment, the transaction verification unit is further specifically configured to determine, if the number of the target node identifiers is smaller than the node reliability threshold, a verification result of the transaction data to be verified as a verification failure result;
and the transaction verification unit is further specifically configured to determine stored serialized block information corresponding to the number of the target node identifiers as to-be-verified serialized block information if the number of the target node identifiers is greater than the node reliability threshold, and perform transaction verification on the to-be-verified transaction data according to the to-be-verified serialized block information and the transaction identifier of the to-be-verified transaction data.
In an embodiment, the transaction verification unit is further specifically configured to obtain a stored transaction identifier of stored transaction data included in the serialized block information to be verified;
the transaction verification unit is further specifically configured to determine that the transaction data to be verified exists in the stored transaction data if the transaction identifier of the transaction data to be verified exists in the stored transaction identifier, and perform transaction verification on the transaction data to be verified according to the mercker root of the stored transaction data included in the serialized block information to be verified;
the transaction verification unit is further specifically configured to determine a verification result of the transaction data to be verified as a verification failure result if the transaction identifier of the transaction data to be verified does not exist in the stored transaction identifiers.
In an embodiment, the transaction verification unit is further specifically configured to obtain an execution result hash value corresponding to the remaining transaction data; the residual transaction data are the transaction data in the stored transaction data except the transaction data to be verified;
the transaction verification unit is specifically used for generating a to-be-verified Mercker root according to the execution result Hash value corresponding to the remaining transaction data and the execution result Hash value corresponding to the to-be-verified transaction data;
the transaction verification unit is specifically used for matching the Mercker root of the stored transaction data with the Mercker root to be verified;
the transaction verification unit is further specifically configured to perform transaction verification on the transaction data to be verified according to a hash value corresponding to the stored transaction data included in the serialized block information to be verified if the matching success result between the mercker root of the stored transaction data and the mercker root to be verified is obtained;
the transaction verification unit is further specifically configured to determine a verification result of the transaction data to be verified as a verification failure result if a matching failure result is found between the mercker root of the stored transaction data and the mercker root to be verified.
In an embodiment, the transaction verification unit is further specifically configured to obtain a data hash value corresponding to the remaining transaction data;
the transaction verification unit is further specifically used for generating a hash value to be verified according to the data hash value corresponding to the remaining transaction data and the data hash value corresponding to the transaction data to be verified;
the transaction verification unit is specifically used for matching the hash value of the stored transaction data with the hash value to be verified;
the transaction verification unit is specifically used for determining the verification result of the transaction data to be verified as a verification success result if the matching success result is between the hash value of the stored transaction data and the hash value to be verified;
the transaction verification unit is further specifically configured to determine the verification result of the transaction data to be verified as a verification failure result if the hash value of the stored transaction data and the hash value to be verified are a matching failure result.
In one embodiment, the block chain based data processing apparatus further comprises:
the abnormal set determining module is used for determining the uploaded node identifier set corresponding to the target node identifier number as a normal node identifier set and determining the rest node identifier sets as abnormal node identifier sets if the target node identifier number is greater than the node credibility threshold; the rest node identification set is a node identification set except the normal node identification set in stored uploaded node identification sets corresponding to the Q stored serialized block information respectively;
and the shielding processing module is used for determining the uploading node corresponding to the abnormal node identification set as an abnormal node and shielding the abnormal node in a target time period.
An embodiment of the present application provides a computer device, including: a processor and a memory;
the memory stores a computer program which, when executed by the processor, causes the processor to perform the method in the embodiments of the present application.
An aspect of the embodiments of the present application provides a computer-readable storage medium, in which a computer program is stored, where the computer program includes program instructions, and the program instructions, when executed by a processor, perform the method in the embodiments of the present application.
In one aspect of the application, a computer program product or computer program is provided, the computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to cause the computer device to perform the method provided by one aspect of the embodiments of the present application.
In the embodiment of the present application, each node (e.g., SPV node) in a service chain (e.g., a first service chain and a second service chain) may obtain transaction block information (e.g., block header information) in a local service chain in real time, and may send the transaction block information to a relay chain for storage by the relay chain. The relay chain stores the transaction block information through the data storage contract, and the intelligent contract has the characteristic of openness and transparency, so that the reliability of the transaction block information submitted by each node can be well improved; when the relay chain stores the transaction block information, the data structure of the index pair can be stored, the block storage parameter associated with the transaction block information can be used as an index key, and the transaction block information can be used as a part of an index value, so that the index key for indicating the transaction block information in a certain service chain can be generated. Subsequently, after a certain node (e.g., a second node) in a certain service chain (e.g., a second service chain) successfully stores the index pair corresponding to the transaction block information into the relay chain, other service chains (e.g., a first service chain) having a cross-chain transaction requirement with the service chain may send a transaction verification request for the transaction data to be verified in the transaction block information to the relay chain; the index pair corresponding to the transaction block information can be acquired through the transaction verification contract in the relay chain, so that the transaction verification can be performed on the transaction data to be verified based on the transaction block information in the index pair. The transaction verification process of the transaction data to be verified is also completed through the transaction verification contract, and due to the public and transparent characteristics of the intelligent contract, the transaction block information has reliability, and the security and reliability of the transaction verification can be well improved. In conclusion, by adding the relay chain in the cross-chain transaction verification service, the data is not required to be stored by the nodes in the service chain, the situation that the transaction verification is carried out by depending on a single node can be reduced, the transaction data can be stored and verified through an intelligent contract, the reliability and the safety of the transaction data can be better improved, and the safety and the reliability of the transaction verification are further improved. That is to say, the method and the device can improve the reliability of the verification result in the cross-chain transaction service, and further improve the safety of the cross-chain transaction service.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic diagram of a network architecture provided in an embodiment of the present application;
fig. 2a is a schematic view of a scenario in which data is stored in a relay chain according to an embodiment of the present application;
fig. 2b is a schematic view of a scenario of transaction verification through a relay chain according to an embodiment of the present application;
fig. 3 is a schematic flowchart of a data processing method based on a block chain according to an embodiment of the present application;
fig. 4 is a schematic flowchart of a data processing method based on a block chain according to an embodiment of the present application;
FIG. 5 is a block diagram of a system component according to an embodiment of the present disclosure;
FIG. 6 is a logic flow diagram of a data storage contract to store data provided by an embodiment of the present application;
FIG. 7 is a logic flow diagram of transaction verification by a transaction verification contract provided by an embodiment of the present application;
fig. 8 is a schematic structural diagram of a data processing apparatus based on a block chain according to an embodiment of the present application;
fig. 9 is a schematic structural diagram of a computer device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be described clearly and completely with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only some embodiments of the present application, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Referring to fig. 1, fig. 1 is a schematic diagram of a network architecture according to an embodiment of the present disclosure. As shown in fig. 1, the network architecture may include a blockchain cluster 10, a blockchain node cluster 100, and a relay chain 1000. The blockchain cluster 10 may include one or more blockchains, and the number of blockchains is not limited herein. As shown in FIG. 1, the plurality of blockchains may include blockchain 11, blockchain 12, \8230; a blockchain in the blockchain cluster 10 may correspond to a business system, for example, if the business system includes a business system of enterprise a and a business system of enterprise B, where a blockchain 11 is a blockchain configured for the business system of enterprise a, then the blockchain 11 corresponds to the business system of enterprise a, and a blockchain 12 is a blockchain configured for the business system of enterprise B, then the blockchain 12 corresponds to the business system of enterprise B. Each blockchain in the blockchain cluster 10 may be referred to as a blockchain system, which may be a distributed system formed by a plurality of blockchain nodes connected in communication over a network. In other words, all blockchain nodes in each blockchain may establish point-to-point or end-to-end (P2P) connections with each other to form a P2P network (i.e., a blockchain system).
For ease of understanding, the block link points in the block chain will be explained below. The blockchain node may be any type of computer device that is accessed into the blockchain network, for example, the computer device may be a user terminal that is accessed into the blockchain network, and may also be a server that is accessed into the blockchain network, where the specific type of the blockchain node is not limited herein. It is understood that the user terminal herein may include a smart terminal having a data processing function, such as a smart phone, a tablet computer, a notebook computer, and a desktop computer. The user terminal may have a target application (i.e., an application client) installed therein, and when the application client runs in the user terminal, the application client may perform data interaction with other blockchain nodes in the blockchain network shown in fig. 1. The application client may include a social client, a multimedia client (e.g., a video client), an entertainment client (e.g., a game client), an education client, a live client, and other application clients. The application client may be an independent client, or may be an embedded sub-client integrated in a certain client (for example, a social client, an educational client, a multimedia client, and the like), which is not limited herein. The server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a network service, cloud communication, a middleware service, a domain name service, a security service, a CDN, a big data and artificial intelligence platform, and the like.
The main functions of the blockchain nodes in the blockchain include blockchain database, network routing, and the like. Each node has a routing function, but all other functions are not necessarily all, and a core node (i.e., a common node) includes the above functions. Such core nodes may participate in checking, broadcasting transaction data, and tile information, and may discover and maintain connections with other nodes. The core Node will contain a complete blockchain database, including all transaction data, and such a Node containing all functions may also be referred to as a Full Node. Other nodes store only a portion of the blockchain database, typically only the blockchain header information and the transaction data associated with the node itself, and not the complete transaction data. They do transaction Verification in a "Simplified transaction Verification (SPV)" manner, and such nodes may be referred to as Lightweight nodes (Lightweight nodes) or SPV nodes.
The block link points in each block chain as shown in fig. 1 may constitute a block chain node cluster 100. As shown in fig. 1, the blockchain 11 includes a plurality of blockchain nodes such as blockchain nodes 11a and blockchain link points 11b, and the blockchain 12 includes a plurality of blockchain nodes such as blockchain nodes 12a and blockchain link points 12 b; the block chain nodes in the block chains may form a block chain node cluster 100, that is, the block chain node cluster 100 includes a plurality of block chain nodes, such as a block chain node 11a, a block chain node 11b, a block chain node 12a, and a block chain node 12 b.
The relay chain 1000 shown in fig. 1 may be any block chain (the relay chain should be different from any block chain in the block chain cluster 10), and any block chain in the block chain cluster 10 may perform network connection with the relay chain, so that any block chain node (e.g., block chain node 11 a) in any block chain (e.g., block chain 11) may perform data interaction with the relay chain 1000. Taking a block chain as the block chain 11 and a block link point 11a as the SPV node as an example, that is, when a service system corresponding to the block chain 11 generates transaction data, the block chain 11 may generate a block corresponding to the transaction data, at this time, the block link point 11a may obtain block header information of the block, and the block link point 11a may not store the block header information, but transmit the block header information to the relay chain 1000 through a network connection, and the relay chain 1000 stores the block header information, where the block header information may be referred to as block data.
Each of the blockchain nodes shown in fig. 1 may upload the chunk data to the relay chain 1000, and the relay chain 1000 may store the chunk data. For example, the relay link 1000 may include block data 1001a, block data 1001b, block data 1001c, block data 1001d, block data 1001e, and block data 1001f. The tile data 1001a can be uploaded from the tile link point 11a, the tile data 1001b and the tile data 1001c can be uploaded from the tile link point 11b, the tile data 1001d and the tile 1001e can be uploaded from the tile link point 11c, and the tile data 1001f can be uploaded from the deblocking link point 11 d.
It should be understood that each block chain (for example, the block chain 11) in the present application may be referred to as a service chain, and the present application may deploy a data storage contract (blocksavecontact) and a transaction verification contract (txprevecontact) in the relay chain 1000, where the data storage contract and the transaction verification contract are both intelligent contracts, and then when there is a data storage requirement for a certain service chain, the data storage contract in the relay chain 1000 may be directly invoked, and corresponding service data may be stored through an execution logic in the data storage contract. If any two or more than two service chains have cross-chain transaction requirements, and cross-chain transaction needs to be verified, after some service chain in the cross-chain transaction service executes transaction data and uploads the transaction data to the relay chain 1000, other service chains in the cross-beam transaction service can call a transaction verification contract in the relay chain 1000, and the transaction data of the service chain is verified by the transaction verification contract, and after the transaction verification is successful, the service chains can execute transactions which the service chains should do. For specific processes of storing data into the relay chain 1000 and performing transaction verification through the relay chain 1000, reference may be made to the following description in the embodiment corresponding to fig. 3.
It should be understood that by deploying an intelligent contract in the relay chain, and storing the block data (e.g., block header information) in the service chain into the relay chain through the intelligent contract, the corresponding block chain node (e.g., SPV node) does not need to store the corresponding block data, so that when performing transaction verification of cross-chain transaction, the corresponding SPV node does not need to be called, and the problem of transaction verification failure caused by single SPV fault can be avoided; meanwhile, because the intelligent contract has the characteristic of public transparency, the reliability of the block data stored in the relay chain can be improved through the intelligent contract, and therefore when transaction verification is carried out by using the intelligent contract, the safety and the reliability of the transaction verification can be improved.
Further, for convenience of understanding, please refer to fig. 2a, and fig. 2a is a schematic view of a scenario in which data is stored in a relay chain according to an embodiment of the present application. In the scenario shown in fig. 2a, the blockchain node at which each blockchain (also referred to as a service chain) uploads the blockdata to the relay chain is an SPV node (also referred to as a light node). The block link point 12a as shown in fig. 2a may be a block link point 12a in the above-mentioned block chain 12 (which will be referred to as a service chain 12 hereinafter), and the block link point 1000a may be a node in the relay chain 1000. For ease of understanding, the block-link point 12a will be referred to hereinafter as SPV node 12a, and the block-link point 1000a will be referred to as relay node 1000a.
The scenario shown in fig. 2a assumes that the service chain 12 is a blockchain corresponding to enterprise a, and the service chain 11 is a blockchain corresponding to enterprise B. The business chain 12 stores object information (i.e., user information) of business objects (i.e., users) in the enterprise a, and the business chain 11 stores object information of business objects in the enterprise B. A user will typically have accounts in both enterprises, e.g. user a may have account A1 in enterprise a and account B1 in enterprise B. The user a can store virtual asset data in the enterprise A through the account A1 (which can refer to stable currency with stable and circulation characteristics, such as universal currency with price fluctuation ranges like dollars, and can also refer to game virtual currency, such as game gold, game experience values, game credits, game diamonds, and the like), and the user a can also store virtual asset data in the enterprise B through the account B1.
When the user desires to transfer a portion of the virtual asset data (e.g., 100-tuple) in account A1 to account B1, the transfer of the virtual asset data occurs, and for the blockchain, since the enterprise a and the enterprise B correspond to different blockchains, the transfer of the virtual asset data corresponds to a cross-chain transaction. In the cross-chain transaction, the cross-chain transaction is required to be proved, and the cross-chain transaction is proved to be effective to prove a certain transaction. For example, if the user a transfers 100 elements in the account A1 to the account B1, the operation flow at least needs to include the following steps 1-2: 1. in the business chain 12 corresponding to the enterprise A, subtracting 100 yuan from the balance of the account A1 (namely, the total value of the virtual asset data in the account); 2. in the business chain 11 corresponding to business B, 100 yuan is added to the balance of the account B1 (i.e., the total value of the virtual asset data in the account). For the service chain 11, before performing the operation of adding 100 yuan to the balance of the account B1, it needs to determine that the service chain 12 has already performed the operation of subtracting 100 yuan from the balance of the account A1, and the confirmation operation of the service chain 11 is the verification of the transaction of subtracting 100 yuan from the account A1 in the service chain 12; similarly, after the service chain 11 performs the operation of adding 100 yuan to the balance of the account B1, the service chain 12 also needs to verify the transaction of adding 100 yuan to the balance of the account B1, and confirm whether the service chain 11 has been successfully executed.
For each transaction in each block chain (for example, the transaction of subtracting 100 yuan from the balance of the account A1), the block chain generates a corresponding block and stores the block in the block chain, and the SPV node of each block chain may periodically (or through subscription) acquire block header data (also referred to as block header information) of each block in the block chain.
Taking an example that a cross-chain transaction exists between the service chain 12 and the service chain 11, the transaction of the service chain 12 is an account number A1 minus 100 yuan, the transaction may be referred to as transaction data 3, and a block A1 may be generated according to the transaction data 3, where the block A1 may include a block head and a block body; the block body can comprise transaction data 1, transaction data 2, transaction data 3 and transaction data 4; the block body may further include a content data mercker tree corresponding to the transaction data 1, the transaction data 2, the transaction data 3, and the transaction data 4, where the content data mercker tree includes data hash values corresponding to the transaction data 1, the transaction data 2, the transaction data 3, and the transaction data 4 (i.e., hash values calculated according to the content of each transaction data), and a total hash value generated by the data hash values corresponding to the transaction data 1, the transaction data 2, the transaction data 3, and the transaction data 4 (i.e., mercker root corresponding to the hash value of the transaction data, which may be referred to as a first mercker root), the block body may further include an execution result mercker tree corresponding to the transaction data 1, the transaction data 2, the transaction data 3, and the transaction data 4, and the execution result mercker tree includes execution result hash values corresponding to the transaction data 1, the transaction data 2, the transaction data 3, and the transaction data 4, and an execution result mercker value generated by the execution result hash values corresponding to the transaction data 1, the transaction data 2, the transaction data 3, and the transaction data 4 (which may be referred to as a second mercker root); the block header may include a block height of the block a1 (or may be other identification of the block a1 in the service chain 12, such as an identifier and a number of the block a 1), the block header may include transaction identifiers (such as a transaction index and a transaction number) corresponding to the transaction data 1, the transaction data 2, the transaction data 3, and the transaction data 4, respectively, the block header may further include a first mercker root corresponding to the transaction data 1, the transaction data 2, the transaction data 3, and the transaction data 4, and a second mercker root corresponding to the transaction data 1, the transaction data 2, the transaction data 3, and the transaction data 4.
As shown in fig. 2a, the SPV node 12a may periodically obtain the chunk header information in the chunk a1, may also obtain data hash values corresponding to the transaction data 1, the transaction data 2, the transaction data 3, and the transaction data 4, and may also obtain execution result hash values corresponding to the transaction data 1, the transaction data 2, the transaction data 3, and the transaction data 4. The chunk header information, the data hash value of each transaction data, and the execution result hash value may be collectively determined as transaction chunk information 20a, and the spv node 12a may invoke a data storage contract by which the transaction chunk information 20a is transmitted to the relay node 1000a. Subsequently, the relay node 1000a stores the transaction block information 20a into the relay chain 1000 through a data storage contract.
It is understood that, besides the SPV node 12a, other SPV nodes may be included in the service chain 12, and these SPV nodes may also periodically (or in a subscription manner) acquire the chunk header information in the service chain 12, and these SPV nodes also upload the chunk header information and associated information (associated information, such as the data hash value and execution result hash value of each transaction data in the chunk to which the chunk header information belongs) to the relay chain after acquiring the chunk header information. That is, after acquiring the block header information of the block a1, other SPV nodes in the service chain 12 also acquire the data hash values and the execution result hash values corresponding to the transaction data 1-the transaction data 4, so as to form transaction block information (which may be referred to as co-link transaction block information), and send the transaction block information to the relay chain for storage.
Taking the SPV node 12f included in other SPV nodes in the service chain 12 as an example, regarding the block header information of the block a1, the transaction block information generated by the SPV node 12f is transaction block information 20f (may also be referred to as co-chain transaction block information 20 f); subsequently, the SPV node 12f may send the transaction block information 20f to the relay node 1000a, and the relay node 1000a uploads the transaction block information 20f to the relay chain 1000. It is assumed that the SPV node 12f is the first node to send the transaction block information of the block a1 to the relay chain, that is, the block header information of the block a1 does not exist in the relay chain 1000. Then, at this time, the relay chain 1000 may obtain the chain identifier (i.e. 12) of the block chain to which the SPV node 12f belongs and the block height of the block to which the transaction block information 20f belongs (i.e. the block height of the block a1, such as 66), and may form an index key (12, 66) according to the chain identifier 12 and the block height 66; further, the transaction block information 20f may be serialized to obtain serialized transaction block information 20f, and if the serialized transaction block information is obtained as wring2, the wring2 may be referred to as serialized transaction block information 20f; subsequently, an upload node identification set {12f } may be generated according to the upload node (i.e., SPV node 12 f) and the upload node identification (i.e., 12 f) corresponding to the serialized transaction block information 20f, an index value may be generated according to the serialized transaction block information 20f, the upload node identification set {12f } and the number 1 of node identifications of the upload node identification set {12f }, an association mapping relationship may be established between the index value and the index key (12, 66), that is, an index pair (the number of the index pair may be 1001 h) may be generated by the index key (12, 66) and the index value, for understanding, please refer to table 1 together, and the index pair shown in table 1 may be an index pair 1001h composed of the index key (12, 66) and the index value.
Figure RE-GDA0003288476180000141
As shown in table 1, the index pair 1001h may include an index key and an index value, where the index key is (12, 66) used to indicate that the index pair belongs to the block a1 in the service chain 12; the index value includes serialized block information (including serialized block information 20f, i.e., wrapg 2), an upload node id set (including a node id 12f of the SPV node 12 f), and a node id number (i.e., the number of uploaded serialized block information 20f, i.e., the number of node ids of the upload node id set, is 1).
It should be understood that the index pair may be numbered (e.g., 1001 h), and then the index pair may be referred to as the index pair 1001h (the index may also be referred to as the chunk data, and then the index pair 1001h may also be referred to as the chunk data 1001 h), and the index pair 1001h is stored in the relay chain 1000. After transaction block information corresponding to the block a1 uploaded by other SPV nodes (including the SPV node 12 a) in the service chain 12 is subsequently received, if the transaction block information uploaded by other SPV nodes (such as the SPV node 12 u) is consistent with the transaction block information 20f, the node identifier 12u of the SPV node 12u may be directly added to an uploading node identifier set corresponding to the serialized block information 20f (namely, ring2, which will be referred to as serialized block information ring2 hereinafter), and the number of the node identifiers corresponding to the node identifier 12u is incremented; if the transaction block information uploaded by other SPV nodes (e.g., SPV node 12 c) is inconsistent with the transaction block information 20f, a new serialized block information (e.g., wring 1) can be generated according to the transaction block information uploaded by SPV node 12c, and the new serialized block information wring1, the uploaded node identifier set (i.e., {12c }) corresponding to the serialized block information wring1, and the number of node identifiers (i.e., 1) are stored in the index value in an associated manner. That is, the index pair 1001h may be continuously updated.
Through the above, after receiving the transaction block information 20a sent by the SPV node 12a, the specific process of the relay chain 1000 for storing the transaction block information 20a may be as follows: first, the chain identifier (i.e. 12) of the block chain to which the SPV node 12a belongs and the block height of the block to which the transaction block information 20a belongs (i.e. the block height of the block a1, as 66) may be obtained; it should be understood that the index key (12, 66) can be formed according to the chain identifier of the service chain 12 and the block height of the block a1; subsequently, the stored index pair (including the stored index pair 1001g, the stored index pair 1001h, and the stored index pair 1001i. Here, the index pair already stored in the relay chain 1000 is referred to as the stored index pair) in the relay chain 1000 may be traversed to query whether the stored index key (here, the index key already stored in the relay chain 1000, which is referred to as the stored index key, is the same as the index key (12, 66) in the stored index pair (here, the index keys respectively included in the stored index pair 1001g, the stored index pair 1001h, and the stored index pair 1001i, which are stored index keys).
Further, as a result of traversal, if the stored index key in the stored index pair 1001h is the same as the index key (12, 66), then the stored index pair 1001h can be obtained. The index key and index value of the index included in the stored index pair 1001h may be as shown in FIG. 2 a. Further, the transaction block information 20a may be serialized to obtain serialized block information 20a as wing 2, and then stored serialized block information in the index value (i.e., serialized block information already stored in relay chain 1000, as shown in fig. 2a, the stored serialized block information includes serialized block information wing 1 and serialized block information wing 2) may be traversed to query whether the stored serialized block information of the stored indexed pair 1001h includes stored serialized block information identical to the serialized block information 20a (wing 2). As shown in fig. 2a, it can be known through traversal that the stored serialized block information wring2 is the same as the serialized block information 20a, at this time, the node identifier 12a of the SPV node 12a can be directly added to the upload node identifier set corresponding to the stored serialized block information wring2, and the node identifier number 2 corresponding to the stored serialized block information wring2 is incremented to obtain the node identifier number of 3, so that a new index pair 1001h can be obtained.
Further, it may be determined that the transaction block information 20a is successfully stored into the relay chain 1000 after the addition is completed, at which point the relay node 1000a may send a storage success notification to the SPV node.
Further, please refer to fig. 2b, wherein fig. 2b is a schematic view of a scenario of performing transaction verification through a relay chain according to an embodiment of the present application. It should be understood that after the service chain 12 performs subtracting 100 yuan from the balance of the account A1 (i.e., performs the transaction data 3), the service chain 12 may send a completion notification for the transaction data 3 to the service chain 11 to notify the service chain 12 that the transaction data 3 has been performed, and the service chain 11 may perform subsequent operations (e.g., adding 100 yuan to the balance of the account B1). The transaction of adding 100 yuan to the balance of the account B1 may be referred to as transaction data w, and before the transaction data w is self-transacted, the business chain 11 needs to perform transaction verification on the transaction data 3.
As shown in fig. 2b, the specific process of the service chain 11 performing transaction verification on the transaction data 3 may be: the block link node 11a in the service chain 11 may send a transaction verification request to the relay node 1000a, where the transaction verification request may carry a chain identifier (i.e. 12) of the service chain 12, a block height (i.e. 66) of a block (i.e. block a 1) to which the transaction data 3 belongs (which may be carried in the execution completion notification sent by the service chain 11), and may also carry a transaction identifier (i.e. 3) of the transaction data 3. Further, the relay node 1000a may traverse the relay chain 1000 to query the stored index key that is the same as the chain identifier 12 and the block height 66 carried in the transaction verification request, and since the index key included in the stored index pair 1001h is (12, 66), the stored index pair 1001h may be obtained by traversing.
It should be appreciated that because malicious nodes may exist in the blockchain, the transaction blockinformation that these malicious nodes have occurred into the relay chain 1000 may not be the actual information. At this time, the transaction block information sent by the malicious node is different from the transaction block information sent by the normal node, and the serialized block information corresponding to the malicious node and the normal node is also different. Since normal nodes in the block chain are usually higher in proportion and the number of malicious nodes is small, in the application, in the stored index pair, the serialized block information with the largest node identification number is sent by the normal nodes with a high probability, so that the maximum value of the node identification number in the index value can be obtained during transaction verification, and subsequent transaction verification is performed according to the maximum value.
For example, in the stored index pair 1001h, the number of node identifiers is at most 3, that is, 3 SPV nodes upload the same transaction block information. At this time, the maximum node identification number 3 may be compared with a node reliability threshold, where the node reliability threshold may be half of the total number of all SPV nodes in the service chain 12, for example, if there are 5 SPV nodes in the service chain 12, the node reliability threshold may be 2.5 (alternatively, the node reliability threshold may be determined to be 3 by rounding up). If the maximum node identifier number is greater than the node reliability threshold, it may be considered that the serialized block information wring2 is actually uploaded by the normal node, and the serialized block information wring2 is reliable.
Further, the transaction data that the service chain 11 desires to verify can be determined to be the transaction data 3 according to the transaction identifier of the transaction data to be verified (i.e., the transaction data 3), and the relay node 1000a can perform transaction verification on the transaction data 3 according to the serialized block information wring2. The content of the verification includes but is not limited to the following 3 aspects: (1) verifying the presence of transaction data 3; (2) Verifying the execution state of the transaction data 3 (whether the execution result of the transaction data 3 is successful or failed); (3) The content of the transaction data 3 (it can be understood whether the transaction chain 12 subtracts in account A1 to be really 100 yuan). For a specific process of transaction verification of the transaction data 3, reference may be made to the description of the embodiment corresponding to fig. 3.
After the transaction data 3 is subjected to transaction verification, a verification result may be obtained, and the relay node 1000a may send the verification result to the block link node 11a, so that the service link 11 may perform subsequent processing according to the verification result. For example, if the verification result is a successful verification result, the service chain 11 may add 100 yuan to the balance in the account B1; if the verification result is a verification failure result, the service chain 11 may not perform the operation of adding 100 yuan to the balance of the account B1.
It should be understood that in the transaction verification of the cross-link transaction, by adding the relay link, the SPV node of each service link (i.e. the block link) does not need to store the block header information, but only needs to upload the block header information to the relay link, and the block header information is stored by the relay link; meanwhile, when the data are uploaded to the relay link by the SPV, the SPV node does not need to be transformed to a great extent, only the original transaction data need to be converted into transaction data conforming to the transaction data format of the relay link, and then the converted transaction data (also called as converted transaction data) are sent to the relay link; meanwhile, the relay chain in the application can be any block chain, special development is not needed, and the deployment cost is low. Through the relay chain, the single SPV node can be prevented from being called during transaction verification, so that the problem that the transaction verification cannot be smoothly carried out due to the fact that the SPV node breaks down can be avoided. Moreover, the storage and verification of the data are completed through the intelligent contract, and the safety and the reliability of transaction verification can be greatly improved due to the public transparency of the intelligent contract.
It should be noted that the parameters of the transaction data (for example, the transaction data 3, which is obtained by subtracting 100 yuan from the balance of the account A1), the identification of the transaction data, the results obtained by performing the serialization processing on the transaction block information (for example, winding 2 and winding 1), and the like are all for convenience of understanding, and are not limited to actual reference.
Further, referring to fig. 3, fig. 3 is a schematic flowchart of a data processing method based on a block chain according to an embodiment of the present application, where the flow may actually correspond to a flow in which a service chain stores data into a relay chain, and the flow may be executed by a computer device, and the computer device may be any block chain node in the relay chain 1000 shown in fig. 1. As shown in fig. 3, the process may include the following steps S101 to S104:
step S101, acquiring a data storage request aiming at the transaction block information sent by the second node; the data storage request carries the block height of the block to which the transaction block information belongs.
Specifically, a service chain may refer to a block chain corresponding to a certain service, and each service chain may store service data (such as transaction information) of the corresponding service. The service may include an invoice service, an export service, a legal person service, a credit investigation service, etc., and the services are not illustrated herein. Since the block chain may include a core node, a full node, and a light node (e.g., SPV node), the second node may also be the core node, the full node, or the light node in the second service chain.
It is understood that each service chain may generate a block including transaction data after executing transaction data, and in this application, a node (e.g., SPV node) in the serviceable chain may obtain block information of a block in the local service chain periodically (or in a subscription manner), where the block information includes information that may be used to perform transaction verification on the transaction data, for example, the information that is used to perform transaction verification on the transaction data includes block header information, hash values (i.e., content hash values or data hash values, generated according to the transaction data) of respective transaction data included in the block, hash values (i.e., execution result hash values) corresponding to execution results of respective transaction data, and the like. Information consisting of the chunk header information, the hash value of each transaction data included in the chunk, and the hash value of the execution result of each transaction data may be used as the chunk information (also referred to as transaction chunk information). That is, the transaction block information may be information for performing transaction verification on the transaction data, and specifically may include information consisting of block header information, hash values of the transaction data included in the block, and hash values of execution results of the transaction data.
In this application, a node in a service chain may send transaction block information of each block to a relay chain, taking the service chain as a second service chain and the node as a second node as an example, after acquiring transaction block information of a certain block (hereinafter, referred to as a target block), the second node may generate a data storage request for the transaction block information, and then the second node may send the data storage request, a block height of a block (i.e., the target block) to which the transaction block information belongs (the block height may be used to characterize that the target block is a few blocks in the second service chain), and the block height together to a block link point (hereinafter, referred to as a relay node) in a middle-level chain.
Optionally, the Identity information sent by the second node to the relay node may not be the block height, but may be other Identity information of the target block, where the Identity information may be used to represent that the block to which the transaction block information belongs is the target block, for example, the Identity information may be a block Identifier (ID), a block number, a block name, and the like of the target block.
And step S102, calling a data storage contract in the relay chain according to the data storage request, and determining the chain identifier of the second service chain and the block height of the block to which the transaction block information belongs as block storage parameters through the storage logic of the data storage contract.
Specifically, the relay node may invoke a data storage contract based on the data storage request, and the data storage contract may determine, based on the storage logic (code program logic), a chain identifier of a second service chain to which the second node belongs, and a block height of a block (i.e., a target block) to which the transaction block information belongs, as the block storage parameter. If the chain identifier of the second service chain is 12 and the block height of the block to which the transaction block information belongs is 66, the block storage parameters of the transaction block information may be 12 and 66.
Step S103, determining a target index key according to the block storage parameter, and determining a target index value according to an initial index value corresponding to the target index key, the transaction block information, and the identifier of the second node.
Specifically, the target index key may be determined according to the block storage parameter corresponding to the transaction block information. The specific method comprises the following steps: n stored index pairs in the relay chain may be traversed; wherein a stored index pair is used to indicate a mapping relationship between a stored index key and a stored index value; the stored index key comprises stored block storage parameters associated with the stored block information; if the stored block storage parameters identical to the block storage parameters exist in the stored block storage parameters included in the N stored index pairs, determining a stored index key to which the target stored block storage parameters belong as a target index key; and if the stored block storage parameters which are the same as the block storage parameters do not exist in the stored block storage parameters included in the N stored index pairs, determining an index key consisting of the block storage parameters as a target index key.
It should be understood that the tile storage parameter corresponding to a transaction tile information may constitute an index key (i.e., key value), such as the above tile storage parameters 12 and 66, and may constitute an index key (12, 66) that may be used to characterize the target tile (tile height 66) in the second service chain (chain identification 12). Meanwhile, an index value (i.e., a value) may also be generated according to the transaction block information, an index pair (i.e., a key-value pair) may be generated through the index key and the index value, the over-index pair may be stored in the relay chain, and the index pair stored in the relay chain may represent that the intermediate-level chain has stored the transaction block information, and the transaction block information belongs to the target block in the second service chain. The stored index pair may refer to an index pair corresponding to stored tile information already stored in the relay chain, and since an index pair includes an index key and an index value, the index key included in the stored index pair may be referred to as a stored index key, and the index key included in the stored index pair may be referred to as a stored index value.
It should be understood that, since each node in the service chain sends the transaction block information to the relay chain after obtaining the transaction block information of a certain block, that is, for the same block, the relay node may obtain different transaction block information sent by different nodes (which may include normal transaction block information sent by a normal node, and may also include falsified and erroneous transaction block information sent by an abnormal node), that is, before receiving the transaction block information for the target block sent by the second node, other transaction block information for the target block sent by other nodes in the second service chain (which may be referred to as co-chain transaction block information) may have been received in the relay chain, and for other transaction block information sent by other nodes, the relay chain has generated and stored an index pair (the index key is the chain identification of the second service chain and the block height of the target block, that is, (12, 66)). After determining the block storage parameter (12 and 66) of the transaction block information sent by the second node, traversing the stored index pair in the relay chain, and querying whether a target stored block storage parameter (consisting of the chain identifier of the stored service chain and the block height of the block to which the stored block information belongs) identical to the block storage parameter exists in the stored index key, if so, directly determining the stored index key to which the target stored block storage parameter belongs as the target index key; if not, the index key composed by the block storage parameters can be determined as the target index key.
That is to say, if before the second node sends the transaction block information of the target block, other nodes of the second service chain send other transaction block information for the target block to the intermediate link in priority, at this time, the relay link already has an index key composed of the link identifier of the second service chain and the block height of the target block, and at this time, the index key can be directly used as the target index key of the transaction block information sent by the second node; if the relay node does not receive the transaction block information for the target block sent by other nodes in the second service chain before receiving the transaction block information sent by the second node, the relay node may determine an index key composed of the chain identifier of the second service chain and the block height of the target block as the target index key at this time.
It can be understood that, when the transaction block information sent by any node is acquired, in addition to generating the index key according to the chain identifier of the service chain and the block height of the block to which the transaction block information belongs, an index value needs to be generated according to the transaction block information, and then an index pair is generated by the index key and the index value together. Taking as an example that the relay node does not receive the transaction block information for the target block sent by other nodes in the second service chain before receiving the transaction block information sent by the second node, after the relay node generates a target index key (the chain identifier of the second service chain and the block height of the target block), the transaction block information may be serialized, so that the target serialized block information may be obtained; then, an uploading node identifier set can be formed according to the node identifier of the second node; the relay node may establish an association mapping relationship among the target serialized block information, the upload node identifier set, and the number of node identifiers corresponding to the upload node identifier set, and determine the association mapping relationship as a target index value. Thus, a target index pair composed of the target index key and the target index value can be obtained.
That is, the index key in each index pair is composed of the chain identifier of the service chain and the block height of the block to which the transaction block information belongs; the index value in each index pair may include serialized block information corresponding to the transaction block information, an upload node identifier set for uploading the transaction block information, and a node identifier number of the upload node identifier set. Taking the node identifier of the second node as 12f, and the target serialized block information obtained after the transaction block information is serialized as "winding 2", the target index pair can be as shown in table 1.
It can be understood that, in fact, for each transaction block information, after determining the corresponding index key, the relay node performs serialization processing on the transaction block information, and after obtaining the serialized block information, the relay node traverses the index value (which may be referred to as an initial index value) corresponding to the index key, checks whether the initial index value includes the same serialized block information (that is, other nodes have uploaded), and updates the initial index value according to the query result, so as to obtain a target index value.
Taking the transaction block information sent by the second node as an example, the initial index value includes M (M is a positive integer) association mapping relationships; the incidence mapping relation is used for indicating the incidence relation among stored serialized block information, a stored uploading node identification set corresponding to the stored serialized block information and the number of stored node identifications in the stored uploading node identification set; the specific method for determining the target index value may be: carrying out serialization processing on the transaction block information to obtain target serialized block information; traversing the M pieces of stored serialized block information; if the M pieces of stored serialized block information have the same target stored serialized block information as the target serialized block information, adding the node identification of the second node into a stored uploading node identification set corresponding to the target stored serialized block information, and increasing the number of stored node identifications of the target stored uploading node identification set to obtain a target index value; if the target serialized block information does not exist in the M pieces of serialized block information, a target uploading node identification set corresponding to the target serialized block information is generated according to the node identification of the second node, the number of the node identifications of the second node is used as the number of the target node identifications of the target uploading node identification set, and the target serialized block information, the target uploading node identification set and the number of the target node identifications are added to the initial index key in an associated mode to obtain a target index value.
Before adding the node identifier of the second node to the target uploaded node identifier set corresponding to the target serialized block information, increasing the number of stored node identifiers of the target uploaded node identifier set to obtain a target index value, checking whether the node identifier of the second node exists in the target uploaded node identifier set (that is, the second node may have been uploaded, and at this time, the uploading is repeated), if so, adding is not needed, and if not, adding is performed. The specific method comprises the following steps: traversing stored uploading node identification sets corresponding to the target stored serialized block information; if the node identifier of the second node exists in the uploaded node identifier set corresponding to the target serialized block information, determining the initial index value as a target index value; and if the node identifier of the second node does not exist in the stored uploading node identifier set corresponding to the target stored serialized block information, adding the node identifier of the second node into the stored uploading node identifier set corresponding to the target stored serialized block information, and increasing the number of the stored node identifiers of the target stored uploading node identifier set to obtain a target index value.
That is to say, if the same serialized block information exists in the initial index value and the uploading node identifier set does not have the node identifier of the second node, the node identifier of the second node can be directly added to the corresponding uploading node identifier set, and the number of the corresponding node identifiers is increased progressively; in the scenario shown in fig. 2a, after traversal, it is found that the initial index value contains the same serialized block information wring2, and then the node identifier 12a of the SPV node 12a can be directly added to the previous node identifier set, and the number 3 of the corresponding node identifiers is incremented to 4. If the same serialized block information does not exist in the initial index value, the serialized block information, the upload node identifier set (only including the node identifier of the second node), and the number of node identifiers (i.e., 1) corresponding to the transaction block information can be added to the initial index value in an associated manner.
Step S104, storing the target index pair composed of the target index key and the target index value to the relay chain.
Specifically, if the target index key is a stored index key, the initial index key corresponding to the target index key is updated, and the target index key can be regarded as a stored target index pair.
It should be understood that by adding the relay chain and storing the transaction block information in the service chain in an intelligent contract manner, it is possible to accurately record which nodes upload each transaction block information, and thus it is possible to quickly and accurately determine the normal nodes and the malicious nodes.
Further, please refer to fig. 4, wherein fig. 4 is a schematic flowchart of a data processing method based on a block chain according to an embodiment of the present application. The process may actually correspond to a process in which the service chain performs transaction verification on transaction data through the relay chain, wherein the method may be executed by a computer device, which may be any blockchain node in the relay chain 1000 shown in fig. 1. As shown in fig. 4, the flow may include at least the following steps S201 to S203:
step S201, a transaction verification request sent by a first node in a first service chain is obtained; the transaction verification request carries the information of the chain to be verified and the transaction identification of the transaction data to be verified.
In this application, the first service chain may refer to a block chain corresponding to a certain service, and the first service chain may store service data (such as transaction information) corresponding to the service. The service may include an invoice service, an export service, a legal service, a credit investigation service, and the like, and the services are not illustrated herein. Since the block chain may include a core node, a full node, and a light node (e.g., SPV node), the first node may also be a core node, a full node, or a light node in the first service chain.
It can be understood that, because the service chains (blockchains) configured by different services are actually different, when there is a service interaction demand for two (or more) services, then two (or more) service chains are needed to perform cross-linking, and the service that needs to be performed cross-linking may be referred to as a cross-linking transaction service. Taking a first service chain (a blockchain corresponding to a first service) and a second service chain (a blockchain corresponding to a second service) as an example, in a cross-chain transaction service, after the first service chain executes a certain transaction, the second service chain can execute a subsequent operation, at this time, before the second service chain executes the subsequent operation, it is necessary to verify whether the transaction of the first service chain is really executed, and after it is determined that the transaction of the first service chain is really executed, the second service chain executes the subsequent operation. For an example of a scenario corresponding to a cross-chain transaction service, reference may be made to the description of the scenario corresponding to the cross-chain transaction service in the embodiments corresponding to fig. 2a to fig. 2b, and an example description of the cross-chain transaction is not repeated here.
It should be understood that, as described in the embodiment corresponding to fig. 3, transaction block information of each service chain may be stored in the relay chain. Then the first node may send a transaction verification request to the relay node when the first service chain has a transaction verification requirement for certain transaction data to be verified. The transaction verification request needs to carry information of a chain to be verified, and the information of the chain to be verified is related information of the service chain to be verified. Taking the cross-chain transaction existing between the first service chain and the second service chain as an example, after the second service chain executes a certain transaction, the second service chain may send an execution completion notification to the first service chain (to inform the second service chain that the transaction has been completed, and at the same time, may notify the first service chain of transaction information used for transaction verification, such as the block height of the block to which the transaction belongs, the transaction identifier (e.g., ID) of the transaction, and the like), so that the first service chain may use the transaction as transaction data to be verified, and the chain identifier of the second service chain and the block height of the block to which the transaction data to be verified belong as the information of the transaction chain to be verified; subsequently, the first service chain may send the to-be-verified chain information and the transaction identifier of the to-be-verified transaction data to the relay node.
Step S202, a transaction verification contract on the relay chain is called based on the transaction verification request, and a target index pair is obtained in the relay chain through the transaction verification contract and the information of the chain to be verified; the target index pair is generated when transaction block information is stored by the data storage contract, the transaction block information being sent by a second node in the second service chain; the target index pair is used for indicating the mapping relation between a target index key and a target index value, the target index key comprises a block storage parameter associated with transaction block information, and the block storage parameter is matched with the information of the chain to be verified; the target index value comprises transaction block information; the first service chain is different from the second service chain.
In the present application, as can be seen from the embodiment corresponding to fig. 3, the manner of storing the information of each transaction block by the intermediate link is as follows: the data structure of the pair is stored in an index. When transaction verification is performed on the transaction data to be verified, the transaction block information of the block to which the transaction data to be verified belongs needs to be acquired first. It can be specifically: the relay node may invoke a transaction verification contract based on the transaction verification request, and the transaction verification contract may obtain the target index pair based on contract logic (verification logic, i.e., code logic), and then obtain corresponding transaction block information in the target index pair. The specific way of obtaining the target index pair may be: traversing the N stored index pairs in the relay chain through validation logic in the transaction validation contract; a stored index pair for indicating a mapping between a stored index key and a stored index value; the stored index key comprises stored block storage parameters associated with the stored block information; the stored index key comprises stored block storage parameters, and the stored block storage parameters comprise stored chain identification and stored block height; the stored chain identifier is a chain identifier of a stored service chain, the stored block height is the block height of the block to which the stored block information belongs, and the block to which the stored block information belongs to the stored service chain; the stored block information comprises transaction block information, the N stored index pairs comprise index pairs corresponding to the transaction block information, stored chain identification in the index pairs corresponding to the transaction block information is chain identification of a second service chain, the stored block height in the index pairs corresponding to the transaction block information is the block height of a block to which the transaction block information belongs, and the block height of the block to which the transaction block information belongs is the same as the block height of a block to which the to-be-verified transaction data belongs; and determining the index pair corresponding to the transaction block information, wherein the stored chain identification in the N stored index pairs is matched with the chain identification of the second service chain, and the stored block height is matched with the block height of the block to which the transaction data to be verified belongs, as a target index pair.
It should be understood that, because the transaction block information uploaded by the second service chain includes the transaction block information of the block to which the transaction data to be verified belongs, and because the chain information to be verified includes the chain identifier of the second service chain and the block height of the block to which the transaction data to be verified belongs, after traversing the stored index pair, obtaining a target index key whose chain identifier is the chain identifier of the second service chain and whose stored block height is the block height of the block to which the transaction data to be verified belongs, and further obtaining a target index pair to which the target index key belongs. The target index value in the target index pair contains the transaction block information of the block to which the transaction data to be verified belongs.
Step S203, transaction verification is carried out on the transaction data to be verified based on the transaction identification of the transaction data to be verified and the transaction block information in the target index value, and a verification result is sent to the first node.
In the present application, as can be seen from the embodiment corresponding to fig. 3, each index value includes one or more serialized block information, an upload node identifier set corresponding to each serialized block information, and a node identifier number of the upload node identifier set, that is, the target index value includes Q (Q is a positive integer) associated mapping relationships; an association mapping relationship is used for indicating an association relationship among stored serialized block information, a stored uploading node identification set corresponding to the stored serialized block information and the number of stored node identifications in the stored uploading node identification set; the stored serialized block information is information obtained by performing serialization processing on stored block information, and the Q pieces of stored serialized block information comprise target serialized block information corresponding to the transaction block information. The specific method for transaction verification of the transaction data to be verified can be as follows: acquiring the number of stored node identifiers corresponding to the target serialized block information; taking the maximum stored node identification number in the stored node identification numbers respectively corresponding to the residual stored serialized block information as the number of the node identifications to be compared, and comparing the number of the node identifications to be compared with the stored node identification number corresponding to the target serialized block information; the remaining stored serialized block information is stored serialized block information in addition to the target serialized block information in the Q stored serialized block information; determining the number of stored node identifications corresponding to the target serialized block information and the maximum node identification number in the number of node identifications to be compared as the number of target node identifications; and performing transaction verification on the transaction data to be verified according to the number of the target node identifiers and the transaction identifier of the transaction data to be verified.
According to the number of the target node identifiers and the transaction identifier of the transaction data to be verified, the specific implementation manner of performing transaction verification on the transaction data to be verified can be as follows: if the number of the target node identifications is smaller than the node credibility threshold, determining the verification result of the transaction data to be verified as a verification failure result; and if the number of the target node identifications is greater than the node reliability threshold, determining the stored serialized block information corresponding to the number of the target node identifications as the serialized block information to be verified, and performing transaction verification on the transaction data to be verified according to the serialized block information to be verified and the transaction identification of the transaction data to be verified.
The specific method for transaction verification of the transaction data to be verified according to the serialized block information to be verified and the transaction identifier of the transaction data to be verified may be as follows: acquiring stored transaction identification of stored transaction data contained in serialized block information to be verified; if the transaction identification of the transaction data to be verified exists in the stored transaction identification, determining that the transaction data to be verified exists in the stored transaction data, and performing transaction verification on the transaction data to be verified according to the Mercker root of the stored transaction data contained in the serialized block information to be verified; and if the transaction identification of the transaction data to be verified does not exist in the stored transaction identification, determining the verification result of the transaction data to be verified as a verification failure result.
For the mercker root of the stored transaction data contained in the serialized block information to be verified, the specific method for performing transaction verification on the transaction data to be verified may be as follows: obtaining an execution result hash value corresponding to the residual transaction data; the residual transaction data are the transaction data in the stored transaction data except the transaction data to be verified; generating a to-be-verified Merck root according to the execution result hash value corresponding to the residual transaction data and the execution result hash value corresponding to the to-be-verified transaction data; matching the Merck root of the stored transaction data with the Merck root to be verified; if the matching success result is between the Mercker root of the stored transaction data and the Mercker root to be verified, transaction verification is carried out on the transaction data to be verified according to the hash value corresponding to the stored transaction data contained in the serialized block information to be verified; and if the matching failure result is between the Mercker root of the stored transaction data and the Mercker root to be verified, determining the verification result of the transaction data to be verified as a verification failure result.
For the hash value corresponding to the stored transaction data included in the serialized block information to be verified, the specific method for performing transaction verification on the transaction data to be verified may be as follows: acquiring a data hash value corresponding to the residual transaction data; generating a hash value to be verified according to the data hash value corresponding to the residual transaction data and the data hash value corresponding to the transaction data to be verified; matching the hash value of the stored transaction data with the hash value to be verified; if the matching success result is between the hash value of the stored transaction data and the hash value to be verified, determining the verification result of the transaction data to be verified as a verification success result; and if the matching failure result is between the hash value of the stored transaction data and the hash value to be verified, determining the verification result of the transaction data to be verified as the verification failure result.
It should be understood that, since the target index value actually includes the serialized block information (already stored, which may be referred to as stored serialized block information) corresponding to the transaction block information sent by different nodes, for example, as shown in the embodiment corresponding to fig. 2a, the index pair 1001h corresponds to the serialized block information wring1 for the node 12c and the serialized block information wring2 for the node 12f, the node 12h and the node 12u for the same block in the same service chain. Because there may be a small number of malicious nodes in the upload nodes, and the serialized block information corresponding to the malicious nodes is not consistent with the serialized block information corresponding to the normal nodes, because the number of malicious nodes is small and the number of normal nodes is large, in the index value, the serialized block information with the largest node identification number is most likely to be the normal information sent by the normal nodes, and then after the target index value is obtained, the maximum value of the stored node identification numbers (which may be the stored node identification number corresponding to the target serialized block information, or the stored node identification number corresponding to other serialized block information) may be obtained. Further, the maximum value may be compared with a reliability node threshold (the reliability node threshold may be a half of the total number of all upload nodes in the entire service chain or other ratio, for example, if the second service chain uploads the transaction block information to the relay chain is an SPV node, the reliability threshold may be a half of the total node number of all SPV nodes), if the maximum value is greater than the reliability threshold, it may be determined that the serialized block information corresponding to the maximum value is actually sent by a normal node, the serialized block information may be determined as the serialized block information to be verified, the transaction verification may be performed on the transaction data to be verified according to the serialized block information to be verified, and the transaction verification may include: verifying the existence of the transaction data to be verified, namely checking whether the transaction data to be verified exists in the serialized block information to be verified through the transaction identifier of the transaction data to be verified, so that whether the transaction data to be verified really exists in the block indicated by the target index key can be determined; when the verification exists indeed, verifying the execution state of the transaction data to be verified, namely verifying whether the transaction data to be verified is a successful execution result or not through an execution result Mercker root in the serialized block information to be verified; after the verification is indeed a successful execution result, the content of the transaction data to be verified can be verified, that is, the hash value of the transaction data to be verified is verified through the data mercker root of the transaction data in the serialized block information to be verified. After the contents are verified, the verification result of the transaction data to be verified can be regarded as a successful verification result.
It should be understood that the transaction verification of the transaction data to be verified is not limited to the above three aspects (i.e. existence, execution status, and content), and may also include other aspects for transaction verification of the transaction data to be verified, which is not limited in this application.
It should be understood that, in the manner provided by the present application, besides transaction verification can be accurately performed on transaction data to be verified, which nodes are abnormal nodes (malicious nodes) can be accurately determined, and the abnormal nodes are shielded and no longer receive data sent by the abnormal nodes. The specific method comprises the following steps: if the number of the target node identifications is larger than the node credibility threshold, determining the uploaded node identification set corresponding to the number of the target node identifications as a normal node identification set, and determining the rest node identification sets as abnormal node identification sets; the rest node identification sets are node identification sets except the normal node identification set in stored uploaded node identification sets respectively corresponding to the Q stored serialized block information; and determining the uploading node corresponding to the abnormal node identification set as an abnormal node, and shielding the abnormal node in a target time period.
In the embodiment of the present application, each node (e.g., SPV node) in a service chain (e.g., a first service chain and a second service chain) may obtain transaction block information (e.g., block header information) in a local service chain in real time, and may send the transaction block information to a relay chain for storage by the relay chain. The relay chain stores the transaction block information through the data storage contract, and the intelligent contract has the characteristic of openness and transparency, so that the reliability of the transaction block information submitted by each node can be well improved; when the relay chain stores the transaction block information, the relay chain can store the transaction block information in a data structure of an index pair, the block storage parameter associated with the transaction block information can be used as an index key, and the transaction block information can be used as a part of an index value, so that the index key used for indicating the transaction block information in a certain service chain can be generated. Subsequently, after a certain node (e.g., a second node) in a certain service chain (e.g., a second service chain) successfully stores the index pair corresponding to the transaction block information into the relay chain, other service chains (e.g., a first service chain) having a cross-chain transaction requirement with the service chain may send a transaction verification request for the transaction data to be verified in the transaction block information to the relay chain; the index pair corresponding to the transaction block information can be acquired through the transaction verification contract in the relay chain, so that the transaction verification can be performed on the transaction data to be verified based on the transaction block information in the index pair. The transaction verification process of the transaction data to be verified is also completed through the transaction verification contract, and due to the public and transparent characteristics of the intelligent contract, the transaction block information has reliability, and the security and the reliability of the transaction verification can be well improved. In conclusion, by adding a relay chain in the cross-chain transaction verification service, the data is not required to be stored by the SPV node in the service chain, the situation of transaction verification depending on a single node can be reduced, the transaction data can be stored and verified through an intelligent contract, the reliability and safety of the transaction data can be better improved, and the safety and reliability of the transaction verification can be further improved. That is to say, the method and the device can improve the reliability of the verification result in the cross-chain transaction service, and further improve the safety of the cross-chain transaction service.
Further, for ease of understanding, please refer to fig. 5 together, and fig. 5 is a schematic structural diagram of a system component according to an embodiment of the present application. As shown in fig. 5, the system component structure may include a service chain, a block chain node, a middle-level chain, a service node, and a database. For ease of understanding, the system component structure will be described below.
Different blockchain nodes such as core nodes, full nodes and light nodes (SPV nodes) can be included in the service chain, and the blockchain nodes in the system structure can be SPV nodes in the service chain. The SPV node can periodically poll (or acquire block header data in a local service chain in a subscription mode); subsequently, the SPV node may invoke a data storage contract in the relay chain, and send the block header data to the intermediate link in the form of a relay chain transaction (the SPV node may also send a data storage request to the relay node in the relay chain, and the relay node recalls the data storage contract); further, because the data storage contract is invoked, the data storage contract may write the block header data of the service chain into the database of the relay chain.
The service node may be a node in a service chain of a service party (a party that needs to verify transaction data), and the service node may refer to a block link point that is deployed on a user side and controlled by a user. The business node can call a transaction verification contract, and after the transaction verification contract is called, the business node can acquire the related data stored in the database and execute the related logic to obtain a transaction verification result.
For a specific implementation manner of data storage, reference may be made to the description in the embodiment corresponding to fig. 3, which will not be described herein again; for a specific implementation manner of the transaction verification, reference may be made to the description in the embodiment corresponding to fig. 4, and details will not be described here.
Further, for ease of understanding, please refer to fig. 6, where fig. 6 is a logic flow diagram of a data storage contract storage data provided by an embodiment of the present application. As shown in fig. 6, the logic flow may include at least the following steps S61-S74:
step S61, verifying whether the node submitting the block header information is legal.
Specifically, the block link point (e.g., SPV node) in each service chain (block chain) may periodically obtain the block header information of the block in the local service chain (may also include other block information of the block, for example, may also include hash value information related to each transaction data described above, where the block header information is merely used as an example), and the block link point may submit the block header information to the intermediate-level chain in the form of intermediate-level chain transaction through a data storage contract in the relay chain, and the data storage contract may verify whether the block link point that submits the block header information is legal or not. If it is legal, go to step S63; if not, the process may proceed to step S62.
Step S62 ends.
Specifically, if the node submitting the information is an illegal node, no further logic may be executed.
Step S63, analyzing the data to obtain the specific chain and block header information.
Specifically, the obtained data may be subjected to chain information (such as a chain identifier) of a service chain to which the information submitting node belongs, and specific block header information (which may also include other block information) is obtained, where the block header information includes a block height of a block to which the block header information belongs.
In step S64, it is checked whether the block height specified by the current chain exists.
Specifically, after the service chain identifier to which the node submitting the information belongs is obtained, whether the relay chain currently stores the data of the block height in the service chain or not can be queried. If the relay link has an index key consisting of the link id of the service link and the block height, the following step S65 can be executed; if not, the process may proceed to the next step S73.
In step S65, the relevant data already stored in the relay chain is acquired.
Specifically, the related data (i.e., the index value corresponding to the index key) jointly indicated by the chain identifier and the tile height may be obtained.
Step S66, analyzing the data to form an object set, and traversing the object set.
Specifically, each piece of serialized block information in the index value may be obtained, each piece of serialized block information may form an object set, and traversing the object set is to traverse each piece of serialized block information.
Step S67 determines whether the serialized block information of the two blocks is consistent.
Specifically, the information submitted by the node that submits the information currently may be serialized, and the target serialized block information obtained after the serialization processing may be compared with each piece of serialized block information in the object set to determine whether the two pieces of serialized block information are identical. If a certain serialized block information in the object set is consistent with the target serialized block information, then the subsequent step S70 can be entered; if the serialized block information in the object set does not match the target serialized block information, the process proceeds to step S68.
Step S68, judging whether the object set is traversed to be ended or not.
Specifically, if a certain piece of serialized block information in the object set is inconsistent with the target serialized block information, it can be determined whether all traversal of the object set is completed, and if not, step S66 can be performed to continue the loop traversal. If the traversal is completed, the process may proceed to the following step S69.
In step S69, a record is added to the index value corresponding to the index key.
Specifically, the record is a mapping relationship formed by the target serialized block information, the uploaded node identifier set (formed by the node identifiers of the currently submitted nodes), and the number of node identifiers (the number of the node identifiers is 1), and the record can be added to the index value. After the addition is completed, the subsequent step S71 may be entered.
And step S70, judging whether the uploading node identification set contains the node.
Specifically, if yes, the process may proceed to the next step S71; if not, the process may proceed to step S72.
Step S71 ends.
Step S72, adding the node identifier of the currently submitted node to the uploading node identifier set corresponding to the target serialized block information, and incrementing the number of the node identifiers (i.e., + 1). After the execution is completed, the process may proceed to step S71.
In step S73, the currently submitted information (i.e., the current block information) is serialized and written into the relay link.
Step S74, adding a record to the index value corresponding to the index key.
Specifically, the record is a mapping relationship formed by the target serialized block information, the uploaded node identifier set (formed by the node identifiers of the currently submitted nodes), and the number of node identifiers (the number of the node identifiers is 1), and the record can be added to the index value. After the addition is completed, the process may proceed to step S71.
Specifically, for a specific implementation manner of the step S61 to the step S74, reference may be made to the description in the embodiment corresponding to fig. 3, and details will not be repeated here. The beneficial effects of the same method are not described in detail.
Further, for ease of understanding, please refer to fig. 7, which is a logic flow diagram of a transaction verification contract for transaction verification provided by an embodiment of the present application. As shown in fig. 7, the logic flow may include at least the following steps S81-S87:
step S81, using the chain identification and the block height as indexes to inquire whether the corresponding block information exists.
Specifically, a block chain node (which may be a service node) in a service chain that needs to perform transaction verification on a certain transaction (called transaction data to be verified) may submit a relay chain in a contract input parameter in a manner of invoking a transaction verification contract, where the contract input parameter includes information of the chain to be verified (i.e., a chain identifier of the verified service chain, and a block height of a block to which the transaction data to be verified belongs); the relay chain can inquire whether the relay chain stores related data or not according to the chain identifier and the block height. If so, step S83 may be performed; if not, step 82 may be performed.
And step S82, ending.
Specifically, if there is no relevant data in the intermediate link, it is likely that the node of the party submitting the block information is the node, and the synchronization data is slow (or due to a network reason), so that the relevant block information is not uploaded to the intermediate link, and at this time, a retry prompt message may be returned to the service node, so that the service node performs retry.
And S83, acquiring the corresponding index value and analyzing the index value.
Specifically, if there is related data in the relay chain, the index value jointly indicated by the chain identifier and the block height may be obtained.
In step S84, the largest amount of serialized block information is obtained.
Specifically, in the index value, the serialized block information with the largest number of node identifiers in the uploaded node identifier set may be obtained.
In step S85, it is determined whether the number satisfies a threshold condition.
Specifically, if the maximum number satisfies the threshold condition, the following step S86 may be executed; if not, step S82 may be performed (i.e., end, suggesting a service node retry).
Step S86, transaction verification is performed according to the serialized block information and the input information.
In particular, transaction verification may include, but is not limited to, 3 aspects: 1. proof of existence of the transaction (i.e., verifying that the transaction data to be verified is determined to exist in the block in the verified business chain); 2. the execution state of the transaction is proved (the execution result of the transaction data to be verified and the Mercker root of the execution result of the block to which the transaction belongs can be used for verification); the content of the transaction is certified (which may be determined using a hash of the contract information of the transaction or transaction execution contract). For a specific implementation manner of the transaction verification, reference may be made to the description in the embodiment corresponding to fig. 4, which will not be described herein again.
And step S87, obtaining a verification result.
Specifically, the verification result may include a verification success result and a verification failure result. If the verification is successful, the transaction verification result of the transaction data to be verified can be proved to be successful; if the verification fails, the transaction data to be verified may have a problem, or the normal node may not synchronize the correct block information to the relay link due to the existence of the malicious node when the uplink block information is currently linked. It should be noted that, if the threshold is set to be half of the total number of nodes in the service chain, the problem that the normal node does not synchronize the correct block information to the relay chain due to the existence of the malicious node should not exist, and the service party may determine and confirm the problem.
For a specific implementation manner of the steps S81 to S87, refer to the description in the embodiment corresponding to fig. 4, which will not be described herein again. The beneficial effects of the same method are not described in detail.
Further, please refer to fig. 8, where fig. 8 is a schematic structural diagram of a data processing apparatus based on a block chain according to an embodiment of the present application. The blockchain based data processing apparatus may be a computer program (comprising program code) running in a computer device, e.g. the blockchain based data processing apparatus is an application software; the blockchain based data processing apparatus may be used to perform the methods shown in fig. 3-4. As shown in fig. 8, the block chain-based data processing apparatus 1 may include: an authentication request acquisition module 11, an index pair acquisition module 12, and a transaction authentication module 13.
The verification request obtaining module 11 is configured to obtain a transaction verification request sent by a first node in a first service chain; the transaction verification request carries information of a chain to be verified and a transaction identifier of transaction data to be verified;
the index pair acquisition module 12 is used for calling a transaction verification contract on the relay link based on the transaction verification request;
the index pair obtaining module 12 is further configured to obtain a target index pair in the relay chain through the transaction verification contract and the to-be-verified chain information; the target index pair is generated when transaction block information is stored by the data storage contract, the transaction block information being sent by a second node in the second service chain; the target index pair is used for indicating the mapping relation between a target index key and a target index value, the target index key comprises a block storage parameter associated with transaction block information, and the block storage parameter is matched with the information of the chain to be verified; the target index value comprises transaction block information; the first service chain is different from the second service chain;
the transaction verification module 13 is configured to perform transaction verification on the transaction data to be verified based on the transaction identifier of the transaction data to be verified and the transaction block information in the target index value;
the transaction verification module 13 is further configured to send a verification result to the first node.
For specific implementation manners of the verification request obtaining module 11, the index pair obtaining module 12, and the transaction verification module 13, reference may be made to the descriptions of step S201 to step S203 in the embodiment corresponding to fig. 4, which will not be described herein again.
In one embodiment, the block chain based data processing apparatus 1 may further include: a storage request acquisition module 14, a storage parameter determination module 15, a key determination module 16, a value determination module 17, and a data storage module 18.
A storage request obtaining module 14, configured to obtain a data storage request for the transaction block information sent by the second node; the data storage request carries the block height of the block to which the transaction block information belongs;
the storage parameter determining module 15 is configured to invoke a data storage contract in the relay chain according to the data storage request, and determine, as a block storage parameter, a chain identifier of the second service chain and a block height of a block to which the transaction block information belongs, through a storage logic of the data storage contract;
a key determining module 16, configured to determine a target index key according to the block storage parameter;
a value determining module 17, configured to determine a target index value according to an initial index value corresponding to the target index key, the transaction block information, and an identifier of the second node;
and the data storage module 18 is configured to store a target index pair composed of the target index key and the target index value in the relay chain.
For specific implementation manners of the storage request obtaining module 14, the storage parameter determining module 15, the key determining module 16, the value determining module 17, and the data storage module 18, reference may be made to the descriptions of step S101 to step S104 in the embodiment corresponding to fig. 3, which will not be described herein again.
In one embodiment, the key determination module 16 may include: an index pair traversal unit 161 and a key determination unit 162.
An index pair traversing unit 161 configured to traverse N stored index pairs in the relay chain; a stored index pair for indicating a mapping between a stored index key and a stored index value; the stored index key comprises stored block storage parameters associated with the stored block information;
a key determining unit 162, configured to determine, if there is a target stored chunk storage parameter that is the same as the chunk storage parameter in the stored chunk storage parameters included in the N stored index pairs, a stored index key to which the target stored chunk storage parameter belongs as a target index key;
the key determination unit 162 is further configured to determine an index key composed of chunk storage parameters as a target index key if there is no target stored chunk storage parameter that is the same as the chunk storage parameter in the stored chunk storage parameters included in the N stored index pairs.
For specific implementation manners of the index pair traversing unit 161 and the key determining unit 162, reference may be made to the description in step S203 in the embodiment corresponding to fig. 3, which will not be described herein again.
In one embodiment, the initial index value comprises M associative mapping relationships; the incidence mapping relation is used for indicating the incidence relation among stored serialized block information, a stored uploading node identification set corresponding to the stored serialized block information and the number of stored node identifications in the stored uploading node identification set; m is a positive integer;
the value determining module 17 may include: a serialization processing unit 171, a block information traversal unit 172, and an index value determination unit 173.
A serialization processing unit 171, configured to perform serialization processing on the transaction block information to obtain target serialization block information;
a block information traversal unit 172 for traversing the M serialized block information;
an index value determining unit 173 configured to, if there is target serialized block information that is the same as the target serialized block information in the M pieces of serialized block information, add the node identifier of the second node to the set of uploaded node identifiers corresponding to the target serialized block information, and increment the number of stored node identifiers in the set of uploaded node identifiers to obtain a target index value;
the index value determining unit 173 is further configured to, if there is no target serialized block information in the M pieces of serialized block information, generate a target upload node identifier set corresponding to the target serialized block information according to the node identifier of the second node, use the number of the node identifiers of the second node as the target node identifier number of the target upload node identifier set, and add the target serialized block information, the target upload node identifier set, and the target node identifier number to the initial index key in an associated manner, so as to obtain a target index value.
For specific implementation manners of the serialization processing unit 171, the block information traversal unit 172, and the index value determination unit 173, reference may be made to the description in step S203 in the embodiment corresponding to fig. 3, and details will not be repeated here.
In one embodiment, the value determining module 17 may further include: a set traversal unit 174, a value determination unit 175, and a step execution unit 176.
A set traversing unit 174, configured to traverse a set of uploaded node identifiers corresponding to the target serialized block information;
a value determining unit 175, configured to determine the initial index value as a target index value if a node identifier of the second node exists in the uploaded node identifier set corresponding to the target serialized block information;
the step executing unit 176 is configured to, if the node identifier of the second node does not exist in the stored uploaded node identifier set corresponding to the target stored serialized block information, execute the step of adding the node identifier of the second node to the stored uploaded node identifier set corresponding to the target stored serialized block information, and increment the number of stored node identifiers in the target stored uploaded node identifier set to obtain the target index value.
For specific implementation manners of the set traversing unit 174, the value determining unit 175, and the step executing unit 176, reference may be made to the description in step S203 in the embodiment corresponding to fig. 3, and details will not be repeated here.
In one embodiment, the to-be-verified chain information includes a chain identifier of the second service chain and a block height of a block to which the to-be-verified transaction data belongs;
the index pair obtaining module 12 may include: the traversal unit 121 and the index pair determination unit 122.
A traversal unit 121 configured to traverse N stored index pairs in the relay chain through validation logic in the transaction validation contract; a stored index pair indicating a mapping between a stored index key and a stored index value; the stored index key comprises stored block storage parameters associated with the stored block information; the stored index key comprises stored block storage parameters, and the stored block storage parameters comprise stored chain identification and stored block height; the stored chain identifier is a chain identifier of a stored service chain, the stored block height is the block height of the block to which the stored block information belongs, and the block to which the stored block information belongs to the stored service chain; the stored block information comprises transaction block information, the N stored index pairs comprise index pairs corresponding to the transaction block information, stored chain identification in the index pairs corresponding to the transaction block information is chain identification of a second service chain, the stored block height in the index pairs corresponding to the transaction block information is the block height of a block to which the transaction block information belongs, and the block height of the block to which the transaction block information belongs is the same as the block height of a block to which the to-be-verified transaction data belongs;
the index pair determining unit 122 is configured to determine, as a target index pair, an index pair corresponding to transaction block information in which the stored chain identifier in the N stored index pairs matches the chain identifier of the second service chain and the stored block height matches the block height of the block to which the transaction data to be verified belongs.
The specific implementation manner of the traversal unit 121 and the index pair determination unit 122 may refer to the description in step S202 in the embodiment corresponding to fig. 4, and will not be described again here.
In one embodiment, the target index value includes Q associated mapping relationships; the incidence mapping relation is used for indicating the incidence relation among stored serialized block information, a stored uploading node identification set corresponding to the stored serialized block information and the number of stored node identifications in the stored uploading node identification set; one piece of stored serialized block information is information obtained after one piece of stored block information is serialized, and the Q pieces of stored serialized block information comprise target serialized block information corresponding to the transaction block information; q is a positive integer;
the transaction verification module 13 may include: an identification number comparison unit 131, a target number determination unit 132, and a transaction verification unit 133.
An identifier number comparing unit 131, configured to obtain the stored node identifier number corresponding to the target serialized block information;
the identifier number comparing unit 131 is further configured to use the largest stored node identifier number in the stored node identifier numbers respectively corresponding to the remaining stored serialized block information as the number of the node identifiers to be compared, and compare the number of the node identifiers to be compared with the number of the stored node identifiers corresponding to the target serialized block information; the remaining stored serialized block information is stored serialized block information except the target serialized block information in the Q stored serialized block information;
a target number determining unit 132, configured to determine, as the target node identifier number, the stored node identifier number corresponding to the target serialized block information and the maximum node identifier number in the node identifier numbers to be compared;
and the transaction verification unit 133 is configured to perform transaction verification on the transaction data to be verified according to the number of the target node identifiers and the transaction identifier of the transaction data to be verified.
For specific implementation manners of the identifier quantity comparing unit 131, the target quantity determining unit 132, and the transaction verifying unit 133, reference may be made to the description of step S203 in the embodiment corresponding to fig. 4, and details will not be repeated here.
In an embodiment, the transaction verification unit 133 is further specifically configured to determine, if the number of the target node identifiers is smaller than the node reliability threshold, a verification result of the transaction data to be verified as a verification failure result;
the transaction verification unit 133 is further specifically configured to, if the number of the target node identifiers is greater than the node reliability threshold, determine the stored serialized block information corresponding to the number of the target node identifiers as the serialized block information to be verified, and perform transaction verification on the transaction data to be verified according to the serialized block information to be verified and the transaction identifier of the transaction data to be verified.
In an embodiment, the transaction verification unit 133 is further specifically configured to obtain a stored transaction identifier of stored transaction data included in the to-be-verified serialized block information;
the transaction verification unit 133 is further specifically configured to determine that the transaction data to be verified exists in the stored transaction data if the transaction identifier of the transaction data to be verified exists in the stored transaction identifier, and perform transaction verification on the transaction data to be verified according to the mercker root of the stored transaction data included in the serialized block information to be verified;
the transaction verification unit 133 is further specifically configured to determine, if the transaction identifier of the transaction data to be verified does not exist in the stored transaction identifiers, a verification result of the transaction data to be verified is a verification failure result.
In an embodiment, the transaction verification unit 133 is further specifically configured to obtain an execution result hash value corresponding to the remaining transaction data; the residual transaction data are the transaction data in the stored transaction data except the transaction data to be verified;
the transaction verification unit 133 is further specifically configured to generate a merck root to be verified according to the hash value of the execution result corresponding to the remaining transaction data and the hash value of the execution result corresponding to the transaction data to be verified;
the transaction verification unit 133 is further specifically configured to match the mercker root of the stored transaction data with the mercker root to be verified;
the transaction verification unit 133 is further specifically configured to, if a successful matching result is obtained between the mercker root of the stored transaction data and the mercker root to be verified, perform transaction verification on the transaction data to be verified according to the hash value corresponding to the stored transaction data included in the serialized block information to be verified;
the transaction verification unit 133 is further configured to determine the verification result of the transaction data to be verified as a verification failure result if the matching failure result is between the mercker root of the stored transaction data and the mercker root to be verified.
In an embodiment, the transaction verification unit 133 is further specifically configured to obtain a data hash value corresponding to the remaining transaction data;
the transaction verification unit 133 is further specifically configured to generate a hash value to be verified according to the data hash value corresponding to the remaining transaction data and the data hash value corresponding to the transaction data to be verified;
the transaction verification unit 133 is further specifically configured to match the hash value of the stored transaction data with the hash value to be verified;
the transaction verification unit 133 is further specifically configured to determine, if the hash value of the stored transaction data and the hash value to be verified are a successful matching result, the verification result of the transaction data to be verified is a successful verification result;
the transaction verification unit 133 is further specifically configured to determine the verification result of the transaction data to be verified as a verification failure result if the hash value of the stored transaction data and the hash value to be verified are a matching failure result.
In one embodiment, the block chain based data processing apparatus 1 may further include: an anomaly set determination module 19 and a mask processing module 20.
An abnormal set determining module 19, configured to determine, if the number of target node identifiers is greater than the node reliability threshold, an uploaded node identifier set corresponding to the number of target node identifiers as a normal node identifier set, and determine the remaining node identifier sets as abnormal node identifier sets; the rest node identification sets are node identification sets except the normal node identification set in stored uploaded node identification sets respectively corresponding to the Q stored serialized block information;
and the shielding processing module 20 is configured to determine the uploading node corresponding to the abnormal node identifier set as an abnormal node, and shield the abnormal node in a target time period.
For specific implementation manners of the exception set determining module 19 and the shielding processing module 20, reference may be made to the description in step S203 in the embodiment corresponding to fig. 4, and details are not repeated here.
In the embodiment of the present application, each node (e.g., SPV node) in a service chain (e.g., a first service chain and a second service chain) may obtain transaction block information (e.g., block header information) in a local service chain in real time, and may send the transaction block information to a relay chain for storage by the relay chain. The relay chain stores the transaction block information through the data storage contract, and the intelligent contract has the characteristic of openness and transparency, so that the reliability of the transaction block information submitted by each node can be well improved; when the relay chain stores the transaction block information, the data structure of the index pair can be stored, the block storage parameter associated with the transaction block information can be used as an index key, and the transaction block information can be used as a part of an index value, so that the index key for indicating the transaction block information in a certain service chain can be generated. Subsequently, after a certain node (e.g., a second node) in a certain service chain (e.g., a second service chain) successfully stores the index pair corresponding to the transaction block information into the relay chain, other service chains (e.g., a first service chain) having a cross-chain transaction requirement with the service chain may send a transaction verification request for the transaction data to be verified in the transaction block information to the relay chain; the index pair corresponding to the transaction block information can be acquired through the transaction verification contract in the relay chain, so that the transaction verification can be performed on the transaction data to be verified based on the transaction block information in the index pair. The transaction verification process of the transaction data to be verified is also completed through the transaction verification contract, and due to the public and transparent characteristics of the intelligent contract, the transaction block information has reliability, and the security and reliability of the transaction verification can be well improved. In conclusion, by adding the relay chain in the cross-chain transaction verification service, the data does not need to be stored by the SPV node in the service chain, the situation that transaction verification is performed by depending on a single node can be reduced, and the storage and verification of the transaction data can be performed through the intelligent contract, so that the reliability and safety of the transaction data can be better improved, and the safety and reliability of the transaction verification can be further improved. That is to say, the method and the device can improve the reliability of the verification result in the cross-chain transaction service, and further improve the safety of the cross-chain transaction service.
Further, please refer to fig. 9, wherein fig. 9 is a schematic structural diagram of a computer device according to an embodiment of the present application. As shown in fig. 9, the data processing apparatus 1 based on the block chain in the embodiment corresponding to fig. 8 may be applied to the computer device 1000, where the computer device 1000 may include: the processor 1001, the network interface 1004, and the memory 1005, and the computer apparatus 1000 further includes: a user interface 1003, and at least one communication bus 1002. The communication bus 1002 is used to implement connection communication among these components. The user interface 1003 may include a Display screen (Display) and a Keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a standard wireless interface. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., a WI-FI interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory, such as at least one disk memory. The memory 1005 may optionally be at least one memory device located remotely from the processor 1001. As shown in fig. 9, the memory 1005, which is a kind of computer-readable storage medium, may include therein an operating system, a network communication module, a user interface module, and a device control application program.
In the computer device 9000 shown in fig. 9, a network interface 9004 may provide a network communication function; and user interface 9003 is primarily an interface for providing input to a user; and the processor 9001 may be operative to invoke a device control application stored in memory 9005 to implement:
acquiring a transaction verification request sent by a first node in a first service chain; the transaction verification request carries information of a chain to be verified and a transaction identifier of transaction data to be verified;
calling a transaction verification contract on the relay chain based on the transaction verification request, and acquiring a target index pair in the relay chain through the transaction verification contract and the information of the chain to be verified; the target index pair is generated when transaction block information is stored by the data storage contract, the transaction block information being sent by a second node in the second service chain; the target index pair is used for indicating the mapping relation between a target index key and a target index value, the target index key comprises a block storage parameter associated with transaction block information, and the block storage parameter is matched with the to-be-verified chain information; the target index value comprises transaction block information; the first service chain is different from the second service chain;
and performing transaction verification on the transaction data to be verified based on the transaction identification of the transaction data to be verified and the transaction block information in the target index value, and sending a verification result to the first node.
It should be understood that the computer device 9000 described in this embodiment may perform the description of the data processing method based on the block chain in the embodiments corresponding to fig. 3 to fig. 4, and may also perform the description of the data processing apparatus 1 based on the block chain in the embodiment corresponding to fig. 8, which is not described herein again. In addition, the beneficial effects of the same method are not described in detail.
Further, here, it is to be noted that: an embodiment of the present application further provides a computer-readable storage medium, where a computer program executed by the aforementioned data processing computer device 9000 is stored in the computer-readable storage medium, and the computer program includes program instructions, and when the processor executes the program instructions, the description of the data processing method in the embodiments corresponding to fig. 3 to fig. 4 can be performed, so that details are not repeated here. In addition, the beneficial effects of the same method are not described in detail. For technical details not disclosed in embodiments of the computer-readable storage medium referred to in the present application, reference is made to the description of embodiments of the method of the present application.
The computer-readable storage medium may be the data processing apparatus based on the block chain provided in any of the foregoing embodiments or an internal storage unit of the computer device, such as a hard disk or a memory of the computer device. The computer readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a Smart Memory Card (SMC), a Secure Digital (SD) card, a flash memory card (flash card), and the like provided on the computer device. Further, the computer-readable storage medium may also include both an internal storage unit and an external storage device of the computer device. The computer-readable storage medium is used for storing the computer program and other programs and data required by the computer device. The computer readable storage medium may also be used to temporarily store data that has been output or is to be output.
In one aspect of the application, a computer program product or computer program is provided, the computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to cause the computer device to perform the method provided by one aspect of the embodiments of the present application.
The terms "first," "second," and the like in the description and claims of embodiments of the present application and in the drawings are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "comprises" and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, apparatus, product, or apparatus that comprises a list of steps or elements is not limited to the listed steps or modules, but may alternatively include other steps or modules not listed or inherent to such process, method, apparatus, product, or apparatus.
Those of ordinary skill in the art will appreciate that the elements and algorithm steps of the examples described in connection with the embodiments disclosed herein may be embodied in electronic hardware, computer software, or combinations of both, and that the components and steps of the examples have been described in a functional general in the foregoing description for the purpose of illustrating clearly the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The method and the related apparatus provided by the embodiments of the present application are described with reference to the flowchart and/or the structural diagram of the method provided by the embodiments of the present application, and each flow and/or block of the flowchart and/or the structural diagram of the method, and the combination of the flow and/or block in the flowchart and/or the block diagram can be specifically implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block or blocks of the block diagram. These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block or blocks of the block diagram. These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block or blocks.
The above disclosure is only for the purpose of illustrating the preferred embodiments of the present application and is not to be construed as limiting the scope of the present application, so that the present application is not limited thereto, and all equivalent variations and modifications can be made to the present application.

Claims (15)

1. A data processing method based on a block chain is characterized by comprising the following steps:
acquiring a transaction verification request sent by a first node in a first service chain; the transaction verification request carries information of a chain to be verified and a transaction identifier of transaction data to be verified;
calling a transaction verification contract on a relay chain based on the transaction verification request, and acquiring a target index pair in the relay chain through the transaction verification contract and the information of the chain to be verified; the target index pair is generated when transaction block information is stored by a data storage contract, the transaction block information being sent by a second node in the second business chain; the target index pair is used for indicating a mapping relation between a target index key and a target index value, the target index key comprises a block storage parameter associated with the transaction block information, and the block storage parameter is matched with the to-be-verified chain information; the target index value comprises the transaction block information; the first service chain is different from the second service chain;
and performing transaction verification on the transaction data to be verified based on the transaction identification of the transaction data to be verified and the transaction block information in the target index value, and sending a verification result to the first node.
2. The method of claim 1, further comprising:
acquiring a data storage request aiming at the transaction block information, which is sent by the second node; the data storage request carries the block height of the block to which the transaction block information belongs;
calling the data storage contract in a relay chain according to the data storage request, and determining the chain identifier of the second service chain and the block height of the block to which the transaction block information belongs as the block storage parameter through the storage logic of the data storage contract;
determining the target index key according to the block storage parameters, and determining the target index value according to an initial index value corresponding to the target index key, the transaction block information and the identifier of the second node;
and storing the target index pair consisting of the target index key and the target index value to the relay chain.
3. The method of claim 2, wherein determining the target index key according to the chunk storage parameter comprises:
traversing the N stored index pairs in the relay chain; a stored index pair for indicating a mapping between a stored index key and a stored index value; the stored index key comprises stored block storage parameters associated with stored block information;
if the stored block storage parameters of the N stored index pairs have the same target stored block storage parameters as the block storage parameters, determining a stored index key to which the target stored block storage parameters belong as the target index key;
and if no target stored block storage parameter identical to the block storage parameter exists in the stored block storage parameters of the N stored index pairs, determining an index key formed by the block storage parameters as the target index key.
4. The method according to claim 2, wherein the initial index value comprises M associated mapping relationships; an association mapping relationship is used for indicating an association relationship among stored serialized block information, a stored upload node identifier set corresponding to the stored serialized block information, and the number of stored node identifiers in the stored upload node identifier set; m is a positive integer;
the determining the target index value according to the initial index value corresponding to the target index key, the transaction block information, and the identifier of the second node includes:
carrying out serialization processing on the transaction block information to obtain target serialization block information;
traversing the M pieces of stored serialized block information;
if the M pieces of stored serialized block information have target stored serialized block information which is the same as the target serialized block information, adding the node identifier of the second node into a target stored uploaded node identifier set corresponding to the target stored serialized block information, and increasing the number of stored node identifiers in the target stored uploaded node identifier set to obtain the target index value;
if the target serialized block information does not exist in the M pieces of serialized block information, generating a target uploading node identification set corresponding to the target serialized block information according to the node identification of the second node, taking the number of the node identification of the second node as the number of the target node identification of the target uploading node identification set, and adding the target serialized block information, the target uploading node identification set and the number of the target node identification into the initial index key in an associated manner to obtain the target index value.
5. The method of claim 4, further comprising:
traversing stored uploading node identification sets corresponding to the target stored serialized block information;
if the node identifier of the second node exists in the uploaded node identifier set corresponding to the target serialized block information, determining the initial index value as the target index value;
and if the node identifier of the second node does not exist in the stored uploaded node identifier set corresponding to the target stored serialized block information, the step of adding the node identifier of the second node to the stored uploaded node identifier set corresponding to the target stored serialized block information, and increasing the number of the stored node identifiers of the target stored uploaded node identifier set to obtain the target index value is executed.
6. The method according to claim 1, wherein the to-be-verified chain information comprises a chain identifier of the second service chain and a block height of a block to which the to-be-verified transaction data belongs;
the obtaining of the target index pair in the relay chain through the transaction verification contract and the to-be-verified chain information includes:
traversing, by validation logic in the transaction validation contract, the N stored index pairs in the relay chain; a stored index pair indicating a mapping between a stored index key and a stored index value; the stored index key comprises stored block storage parameters associated with stored block information; the stored index key comprises stored chunk storage parameters comprising a stored chain identification and a stored chunk height; the stored chain identifier is a chain identifier of a stored service chain, the stored block height is a block height of a block to which stored block information belongs, and the stored block information belongs to the stored service chain; the stored block information comprises the transaction block information, the N stored index pairs comprise index pairs corresponding to the transaction block information, the stored chain identifier in the index pair corresponding to the transaction block information is the chain identifier of the second service chain, the stored block height in the index pair corresponding to the transaction block information is the block height of the block to which the transaction block information belongs, and the block height of the block to which the transaction block information belongs is the same as the block height of the block to which the transaction data to be verified belongs;
and determining the index pair corresponding to the transaction block information, wherein the stored chain identification in the N stored index pairs is matched with the chain identification of the second service chain, and the stored block height is matched with the block height of the block to which the transaction data to be verified belongs, as the target index pair.
7. The method according to claim 6, wherein the target index value comprises Q associative mapping relations; an association mapping relationship is used for indicating an association relationship among stored serialized block information, a stored upload node identifier set corresponding to the stored serialized block information, and the number of stored node identifiers in the stored upload node identifier set; one piece of stored serialized block information is information obtained after one piece of stored block information is serialized, and the Q pieces of stored serialized block information comprise target serialized block information corresponding to the transaction block information; q is a positive integer;
the transaction verification of the transaction data to be verified based on the transaction identification of the transaction data to be verified and the transaction block information in the target index value comprises the following steps:
acquiring the number of stored node identifications corresponding to the target serialized block information;
taking the maximum stored node identification number in the stored node identification numbers respectively corresponding to the residual stored serialized block information as the number of the node identifications to be compared, and comparing the number of the node identifications to be compared with the stored node identification number corresponding to the target serialized block information; the remaining stored serialized block information is stored serialized block information in addition to the target serialized block information in the Q stored serialized block information;
determining the number of stored node identifications corresponding to the target serialized block information and the maximum number of node identifications in the number of node identifications to be compared as the number of target node identifications;
and performing transaction verification on the transaction data to be verified according to the number of the target node identifications and the transaction identification of the transaction data to be verified.
8. The method according to claim 7, wherein the performing transaction verification on the transaction data to be verified according to the number of the target node identifiers and the transaction identifier of the transaction data to be verified comprises:
if the number of the target node identifications is smaller than a node reliability threshold value, determining a verification result of the transaction data to be verified as a verification failure result;
and if the number of the target node identifications is greater than the node reliability threshold, determining stored serialized block information corresponding to the number of the target node identifications as to-be-verified serialized block information, and performing transaction verification on the to-be-verified transaction data according to the to-be-verified serialized block information and transaction identifications of the to-be-verified transaction data.
9. The method according to claim 8, wherein the performing transaction verification on the transaction data to be verified according to the serialized block information to be verified and the transaction identifier of the transaction data to be verified comprises:
acquiring stored transaction identification of stored transaction data contained in the to-be-verified serialized block information;
if the transaction identification of the transaction data to be verified exists in the stored transaction identification, determining that the transaction data to be verified exists in the stored transaction data, and performing transaction verification on the transaction data to be verified according to the Merckel root of the stored transaction data contained in the serialized block information to be verified;
and if the transaction identification of the transaction data to be verified does not exist in the stored transaction identification, determining the verification result of the transaction data to be verified as a verification failure result.
10. The method of claim 9, wherein the performing transaction verification on the transaction data to be verified according to the mercker root of the stored transaction data included in the serialized block information to be verified comprises:
obtaining an execution result hash value corresponding to the residual transaction data; the residual transaction data are transaction data in the stored transaction data except the transaction data to be verified;
generating a to-be-verified Merckel root according to the execution result hash value corresponding to the residual transaction data and the execution result hash value corresponding to the to-be-verified transaction data;
matching the Merck root of the stored transaction data with the Merck root to be verified;
if the matching success result is between the Mercker root of the stored transaction data and the Mercker root to be verified, performing transaction verification on the transaction data to be verified according to the hash value corresponding to the stored transaction data contained in the serialized block information to be verified;
and if the Merckel root of the stored transaction data and the Merckel root to be verified are matched failure results, determining the verification result of the transaction data to be verified as a verification failure result.
11. The method according to claim 10, wherein the performing transaction verification on the transaction data to be verified according to the hash value corresponding to the stored transaction data included in the serialized block information to be verified comprises:
acquiring a data hash value corresponding to the residual transaction data;
generating a hash value to be verified according to the data hash value corresponding to the residual transaction data and the data hash value corresponding to the transaction data to be verified;
matching the hash value of the stored transaction data with the hash value to be verified;
if the matching success result is between the hash value of the stored transaction data and the hash value to be verified, determining the verification result of the transaction data to be verified as a verification success result;
and if the hash value of the stored transaction data and the hash value to be verified are the matching failure result, determining the verification result of the transaction data to be verified as the verification failure result.
12. The method of claim 8, further comprising:
if the number of the target node identifications is larger than the node reliability threshold, determining the uploaded node identification set corresponding to the number of the target node identifications as a normal node identification set, and determining the rest node identification sets as abnormal node identification sets; the residual node identification set is a node identification set except the normal node identification set in the uploaded node identification sets respectively corresponding to the Q pieces of serialized block information;
and determining the uploading node corresponding to the abnormal node identification set as an abnormal node, and shielding the abnormal node in a target time period.
13. A blockchain-based data processing apparatus, comprising:
the verification request acquisition module is used for acquiring a transaction verification request sent by a first node in a first service chain; the transaction verification request carries chain information to be verified and a transaction identifier of transaction data to be verified;
the index pair acquisition module is used for calling a transaction verification contract on the relay link based on the transaction verification request;
the index pair obtaining module is further configured to obtain a target index pair in the relay chain through the transaction verification contract and the to-be-verified chain information; the target index pair is generated when transaction block information is stored, the transaction block information being sent by a second node in the second service chain; the target index pair is used for indicating a mapping relation between a target index key and a target index value, the target index key comprises a block storage parameter associated with the transaction block information, and the block storage parameter is matched with the to-be-verified chain information; the target index value comprises the transaction block information;
the transaction verification module is used for performing transaction verification on the transaction data to be verified based on the transaction identification of the transaction data to be verified and the transaction block information in the target index value;
the transaction verification module is further configured to send a verification result to the first node.
14. A computer device, comprising: a processor, memory, and a network interface;
the processor is coupled to the memory and the network interface, wherein the network interface is configured to provide network communication functionality, the memory is configured to store program code, and the processor is configured to invoke the program code to cause the computer device to perform the method of any of claims 1-12.
15. A computer-readable storage medium, in which a computer program is stored which is adapted to be loaded by a processor and to carry out the method of any one of claims 1 to 12.
CN202111005785.8A 2021-08-30 2021-08-30 Data processing method, device and equipment based on block chain and readable storage medium Pending CN115730935A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111005785.8A CN115730935A (en) 2021-08-30 2021-08-30 Data processing method, device and equipment based on block chain and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111005785.8A CN115730935A (en) 2021-08-30 2021-08-30 Data processing method, device and equipment based on block chain and readable storage medium

Publications (1)

Publication Number Publication Date
CN115730935A true CN115730935A (en) 2023-03-03

Family

ID=85290910

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111005785.8A Pending CN115730935A (en) 2021-08-30 2021-08-30 Data processing method, device and equipment based on block chain and readable storage medium

Country Status (1)

Country Link
CN (1) CN115730935A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116827957A (en) * 2023-08-30 2023-09-29 腾讯科技(深圳)有限公司 Information processing method, device, equipment and medium based on multi-block chain
CN116993505A (en) * 2023-09-25 2023-11-03 腾讯科技(深圳)有限公司 Transaction processing method, device, electronic equipment and storage medium

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116827957A (en) * 2023-08-30 2023-09-29 腾讯科技(深圳)有限公司 Information processing method, device, equipment and medium based on multi-block chain
CN116827957B (en) * 2023-08-30 2023-11-07 腾讯科技(深圳)有限公司 Information processing method, device, equipment and medium based on multi-block chain
CN116993505A (en) * 2023-09-25 2023-11-03 腾讯科技(深圳)有限公司 Transaction processing method, device, electronic equipment and storage medium
CN116993505B (en) * 2023-09-25 2024-01-16 腾讯科技(深圳)有限公司 Transaction processing method, device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN111600720B (en) Data processing method, device and equipment based on block chain and readable storage medium
CN108572986B (en) Data updating method and node equipment
US20230037932A1 (en) Data processing method and apparatus based on blockchain network, and computer device
CN112868210A (en) Block chain timestamp protocol
CN109992285B (en) Independent updating method and device for block chain code block and electronic equipment
CN115730935A (en) Data processing method, device and equipment based on block chain and readable storage medium
CN111290742A (en) Parameter verification method and device, electronic equipment and readable storage medium
CN113326165B (en) Data processing method and device based on block chain and computer readable storage medium
CN113256297B (en) Data processing method, device and equipment based on block chain and readable storage medium
CN109391673A (en) A kind of method, system and the terminal device of management update file
CN112988667B (en) Data storage method and device based on block chain network
CN112087530B (en) Method, device, equipment and medium for uploading data to block chain system
CN116155771A (en) Network anomaly test method, device, equipment, storage medium and program
CN112714158A (en) Transaction processing method, relay network, cross-link gateway, system, medium, and device
CN113689216A (en) Cross-chain transaction processing method and device, equipment, storage medium and program product
CN111010282A (en) Information processing method based on block chain and related device
CN111343212B (en) Message processing method, device, equipment and storage medium
CN113806816A (en) Electronic file management method and device based on block chain and electronic equipment
CN111182527B (en) OTA (over the air) firmware upgrading method and device, terminal equipment and storage medium thereof
CN110858211B (en) Data storage method, device and system and storage medium
CN117061538A (en) Consensus processing method and related device based on block chain network
CN112015826B (en) Intelligent contract security detection method based on block chain and related equipment
CN113592645A (en) Data verification method and device
CN110910091A (en) Data processing method, device and medium
CN112989398B (en) Data processing method and device for block chain network, computer equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40083094

Country of ref document: HK