Blockchain-based data processing method, device, equipment, and readable storage medium
By demarcating a molecular chain consensus network and a main chain consensus network in the blockchain network, using the method of bidding and generating and batching of representative nodes, the blockage problem caused by the large amount of transaction data in the blockchain network is solved, and the performance and transaction processing speed of the blockchain are improved.
Patent Information
- Application Number
- CN202111261929.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-28
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2041-10-28
AI Technical Summary
In large blockchain projects, the amount of transaction data generated during the same period is too large, resulting in the block chain rolling speed not keeping up with the generation speed, resulting in blockage and node cache resource occupation, affecting blockchain performance.
The blockchain network is divided into a sub-chain consensus network and a main chain consensus network. By bidding on behalf of the node, the main chain block output permission is obtained, the sub-chain block sequence and hash value are obtained, the main chain block to be put on is generated and batched into the main chain to be turned on is realized to quickly confirm the sub-chain block.
It speeds up the chaining speed of sub-chain blocks, alleviates cache pressure, and improves the transaction processing speed and performance of blockchain networks.
Smart Images

Figure CN116055052B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a blockchain-based data processing method, apparatus, device, and readable storage medium. Background Art
[0002] Blockchain is a chained data structure based on blocks. Blocks use digital summaries to verify previously acquired transaction histories, making them suitable for the tamper-proof and scalability requirements of distributed ledgers. A block is a data packet that carries transaction data (i.e., transactions) on a blockchain network. It is a data structure marked with a timestamp and the hash value of the previous block. Blocks are verified and confirmed by the network's consensus mechanism, confirming the transactions within them.
[0003] Currently, transaction data generated within a blockchain network is ultimately packaged into blocks, which, after consensus, are ultimately written to the same blockchain for storage, facilitating unified management of the entire blockchain network. However, in some large-scale blockchain projects, such as tax blockchains, due to their wide audience and concentrated processing times, the blockchain network generates tens of thousands of transactions within a single timeframe. However, the number of transactions a block can accommodate is limited, leading to a large number of blocks being generated and uploaded to the blockchain within the same timeframe. When the speed of block uploads cannot keep up with the speed of block generation, congestion can easily occur. The cache storage resources of blockchain nodes will be occupied by the large number of blocks waiting to be uploaded, impacting the operational efficiency of blockchain nodes and resulting in poor blockchain performance. Summary of the Invention
[0004] The embodiments of the present application provide a blockchain-based data processing method, apparatus, device, and readable storage medium, which can complete block chaining in batches and improve blockchain performance.
[0005] On the one hand, an embodiment of the present application provides a data processing method based on blockchain, including:
[0006] When the block production authority of the first representative node in the first subchain consensus network becomes the main chain block production authority, a sequence of subchain blocks to be on-chain is obtained; each subchain block to be on-chain in the sequence belongs to the first subchain reached by consensus in the first subchain consensus network; the main chain block production authority is obtained through bidding between the first representative node and the second representative node of the second subchain consensus network;
[0007] Obtain the target main chain parent hash value and the target sub-chain parent hash value; the target main chain parent hash value is the block hash value corresponding to the main chain block with the largest generation timestamp in the main chain; the target sub-chain parent hash value is the block hash value corresponding to the main chain block with the largest generation timestamp in the main chain associated with the first sub-chain in the main chain;
[0008] Generate the main chain block to be on-chain based on the sub-chain block sequence to be on-chain, the target main chain parent hash value, and the target sub-chain parent hash value; the main chain block to be on-chain includes the block header information of each sub-chain block to be on-chain in the sub-chain block sequence to be on-chain;
[0009] Upload the main chain block to be uploaded to the main chain.
[0010] On the one hand, an embodiment of the present application provides a data processing device based on blockchain, including:
[0011] A sequence acquisition module is configured to acquire a sequence of subchain blocks to be uploaded when the block-production authority of the first representative node in the first subchain consensus network is the mainchain block-production authority; each subchain block to be uploaded in the sequence belongs to the first subchain obtained by consensus in the first subchain consensus network; the mainchain block-production authority is obtained through bidding between the first representative node and the second representative node of the second subchain consensus network;
[0012] The hash value acquisition module is used to obtain the parent hash value of the target main chain and the parent hash value of the target sub-chain; the parent hash value of the target main chain is the block hash value corresponding to the main chain block with the largest generation timestamp in the main chain; the parent hash value of the target sub-chain is the block hash value corresponding to the main chain block with the largest generation timestamp in the main chain associated with the first sub-chain in the main chain;
[0013] The main chain block generation module is used to generate the main chain block to be chained based on the sub-chain block sequence to be chained, the target main chain parent hash value, and the target sub-chain parent hash value; the main chain block to be chained includes the block header information of each sub-chain block to be chained in the sub-chain block sequence to be chained;
[0014] The main chain on-chain module is used to link the main chain blocks to be on-chain to the main chain.
[0015] Among them, the main chain block generation module includes:
[0016] The first preparation unit is used to obtain the block header information of each sub-chain block to be chained in the sub-chain block sequence to be chained;
[0017] The first preparation unit is further configured to count the number of sub-chain blocks to be chained in the sequence of sub-chain blocks to be chained, as the first block number;
[0018] The first preparation unit is further configured to generate sub-chain jump information based on the first sub-chain;
[0019] A first generation unit is configured to generate a main chain block body to be chained based on the sub-chain jump information, the block header information of each sub-chain block to be chained in the sub-chain block sequence to be chained, and the number of first blocks;
[0020] The first generation unit is further used to generate a to-be-linked main chain block header according to the target main chain parent hash value and the target sub-chain parent hash value, and to generate a to-be-linked main chain block according to the to-be-linked main chain block body and the to-be-linked main chain block header.
[0021] Among them, the main chain block generation module includes:
[0022] The second preparation unit is used to obtain the to-be-linked sub-chain block with the largest generation timestamp in the to-be-linked sub-chain block sequence as the anchor sub-chain block;
[0023] The second preparation unit is further configured to generate block jump information for the anchor subchain block based on the block hash values of the first subchain and the anchor subchain block;
[0024] The second preparation unit is further configured to determine the difference between the block height of the anchored sub-chain block and the block height of the indirect sub-chain block, and generate indirect jump information corresponding to the indirect sub-chain block based on the block jump information and the height difference; the indirect sub-chain block refers to the sub-chain block to be added to the chain in the sequence of sub-chain blocks to be added, excluding the anchored sub-chain block;
[0025] The second generation unit is used to generate a main chain block body to be uploaded based on the block header information and block jump information of the anchor sub-chain block, the block header information and indirect jump information of the indirect sub-chain block;
[0026] The second generation unit is further used to generate a to-be-linked main chain block header according to the target main chain parent hash value and the target sub-chain parent hash value, and to generate a to-be-linked main chain block according to the to-be-linked main chain block body and the to-be-linked main chain block header.
[0027] The sequence acquisition module includes:
[0028] The block acquisition unit is used to obtain H sub-chain blocks to be on-chained from the node cache; each sub-chain block to be on-chained is a sub-chain block added to the node cache after being written to the first sub-chain; H is a positive integer;
[0029] A sequence generation unit is configured to sequentially obtain I sub-chain blocks to be on-chain from the H sub-chain blocks to be on-chain according to the generation timestamps corresponding to the H sub-chain blocks to be on-chain, and generate a sub-chain block sequence to be on-chain comprising I sub-chain blocks to be on-chain; I is a positive integer less than or equal to H.
[0030] The data processing device further includes:
[0031] A subchain block generation module, configured to receive transaction data associated with a first business sent by a business node and generate a target subchain block based on the transaction data; the first business is associated with the first subchain consensus network;
[0032] The subchain block on-chain module is used to send the target subchain block to the remaining nodes; the remaining nodes are the nodes in the first subchain consensus network except the first representative node;
[0033] The subchain block on-chain module is also used to receive voting information returned by the remaining nodes based on the target subchain block, and determine the consensus result for the target subchain block based on the voting information;
[0034] The sub-chain block on-chain module is also used to add the target sub-chain block to the first sub-chain when the consensus result is a consensus-passed result;
[0035] The cache adding module is used to take the target sub-chain block as the new sub-chain block to be chained, and add the new sub-chain block to be chained into the node cache.
[0036] The data processing device further includes:
[0037] The cache deletion module is used to release the sub-chain blocks to be chained in the sub-chain block sequence to be chained from the node cache after the main chain blocks to be chained are chained to the main chain.
[0038] The data processing device further includes:
[0039] The first auction module is used to obtain the sub-chain blocks to be put on the chain from the node cache, and count the number of blocks of the sub-chain to be put on the chain in the node cache as the second block number;
[0040] The first auction module is further configured to determine the first on-chain asset based on the number of sub-chain blocks to be on-chain and the second block in the node cache, obtain the node identifier of the first representative node, and generate first auction information based on the node identifier and the first on-chain asset;
[0041] The first auction module is further configured to broadcast the first auction information to the main chain consensus network, so that the main chain consensus nodes in the main chain consensus network return the first auction voting information based on the first auction information and the second auction information; the second auction information is generated by the second representative node;
[0042] The first auction module is further configured to determine second auction voting information based on the first auction information and the second auction information;
[0043] The first auction module is further used to determine the block generation authority of the first representative node based on the first auction voting information and the second auction voting information.
[0044] The data processing device further includes:
[0045] The second auction module is used to obtain the sub-chain block to be chained from the node cache, and determine the cache waiting time corresponding to the sub-chain block to be chained in the node cache according to the generation timestamp corresponding to the sub-chain block to be chained in the node cache;
[0046] The second auction module is further configured to determine the first on-chain asset based on the to-be-on-chain sub-chain blocks in the node cache and the cache waiting time, obtain the node identifier of the first representative node, and generate first auction information based on the node identifier and the first on-chain asset;
[0047] The second auction module is further configured to broadcast the first auction information to the main chain consensus network, so that the main chain consensus nodes in the main chain consensus network return the first auction voting information based on the first auction information and the second auction information; the second auction information is generated by the second representative node;
[0048] The second auction module is further configured to determine second auction voting information based on the first auction information and the second auction information;
[0049] The second auction module is further used to determine the block generation authority of the first representative node based on the first auction voting information and the second auction voting information.
[0050] Among them, the main chain on-chain module includes:
[0051] A signature unit, configured to obtain a private key corresponding to the first representative node, and sign the main chain block to be uploaded based on the private key corresponding to the first representative node to obtain a first digital signature;
[0052] The consensus unit is configured to broadcast the first digital signature and the main-chain block to be uploaded to at least two main-chain consensus nodes in the main-chain consensus network, so that the at least two main-chain consensus nodes respectively obtain the public key corresponding to the first representative node, verify the first digital signature based on the public key corresponding to the first representative node, obtain a verification result, and return pre-voting information to the first representative node based on the verification result; determine a first pre-voting result based on the at least two pieces of pre-voting information, and broadcast the first pre-voting result to the at least two main-chain consensus nodes;
[0053] The consensus unit is further configured to receive second pre-voting results respectively sent by at least two main chain consensus nodes;
[0054] The consensus unit is further configured to determine a consensus result based on the first pre-voting result and at least two second pre-voting results;
[0055] The adding unit is used to add the main chain block to the main chain when the consensus result is a consensus passed result.
[0056] The data processing device further includes:
[0057] A query receiving module is configured to receive a transaction query request initiated by a business node for a target transaction in a second business; the second business is associated with a second subchain consensus network; transaction data associated with the second business is stored in the second subchain obtained through consensus by the second subchain consensus network; the transaction query request carries the query subchain block hash value corresponding to the target transaction;
[0058] The query block acquisition module is used to obtain the target query main chain block containing the query sub-chain block hash value from the main chain;
[0059] A data acquisition module, configured to initiate a data query request to the second representative node based on the target query main chain block, so that the second representative node returns transaction data associated with the target transaction based on the data query request;
[0060] The result return module is used to send the transaction data associated with the target transaction as the transaction query result to the business node.
[0061] Among them, the query block acquisition module includes:
[0062] A first query unit is configured to obtain, from the main chain, a main chain block having a minimum generation timestamp among the main chain blocks associated with the second subchain, as a first query main chain block;
[0063] A first block acquisition unit is configured to use the first query main chain block as a target query main chain block if a query sub-chain block hash value is found in the first query main chain block;
[0064] The second query unit is configured to obtain the block hash value of the first query main chain block if the query sub-chain block hash value is not found in the first query main chain block, and obtain a main chain block in the main chain whose sub-chain parent hash value is the block hash value of the first query main chain block as the second query main chain block;
[0065] The second block acquisition unit is configured to use the second query main chain block as the target query main chain block if the query sub-chain block hash value is found in the second query main chain block.
[0066] The data acquisition module includes:
[0067] A jump information acquisition unit, configured to acquire query jump information for a query sub-chain block hash value in a target query main-chain block;
[0068] The data query unit is used to initiate a data query request carrying query jump information to the second representative node, so that the second representative node obtains the target query subchain block corresponding to the query subchain block hash value according to the query jump information, obtains the transaction data associated with the target transaction from the target query subchain block, and sends the transaction data associated with the target transaction to the first representative node.
[0069] On one hand, an embodiment of the present application provides a computer device, including: a processor, a memory, and a network interface;
[0070] The above-mentioned processor is connected to the above-mentioned memory and the above-mentioned network interface, wherein the above-mentioned network interface is used to provide a data communication network element, the above-mentioned memory is used to store a computer program, and the above-mentioned processor is used to call the above-mentioned computer program to execute the method in the embodiment of the present application.
[0071] On one hand, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. The computer program is suitable for being loaded by a processor and executing the method in the embodiment of the present application.
[0072] On the one hand, an embodiment of the present application provides a computer program product or a computer program, which includes computer instructions, which are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method in the embodiment of the present application.
[0073] In an embodiment of the present application, the consensus network in the blockchain network can be divided into different sub-chain consensus networks and a main-chain consensus network. Each sub-chain consensus network is responsible for processing a business, and can package the transactions generated for that business into sub-chain blocks, and then reach consensus on the sub-chain blocks. The sub-chain blocks that pass the consensus are added to the corresponding sub-chain (hereinafter referred to as the sub-chain). The sub-chain blocks added to the sub-chain need to be submitted to the main blockchain corresponding to the main-chain consensus network (hereinafter referred to as the main chain) so that by accessing the main chain, the transactions processed by each sub-chain consensus network can be queried. Each sub-chain consensus network can select a representative node to compete for the main chain's block generation authority, thereby completing the chaining of the sub-chain blocks in the corresponding sub-chain. In this application, when the block generation authority of the first representative node in the first sub-chain consensus network is the main chain block generation authority, the first representative node can obtain the sub-chain block sequence to be chained, and then obtain the target main chain parent hash value and the target sub-chain parent hash value. According to the sub-chain block sequence to be chained, the target main chain parent hash value and the target sub-chain parent hash value, it generates the main chain block to be chained, and chains the main chain block to be chained to the main chain. Among them, each sub-chain block to be chained in the sub-chain block sequence to be chained belongs to the first sub-chain obtained by consensus of the first sub-chain consensus network. Through the method provided in the embodiment of the present application, when the representative node in the sub-chain consensus network bids for the main chain block generation authority, it can generate the main chain block to be chained according to the sub-chain block sequence to be chained, thereby realizing batch processing of continuous sub-chain blocks on the chain, speeding up the speed at which sub-chain blocks are confirmed by the main chain, and alleviating cache pressure. At the same time, each sub-chain consensus network can continuously execute transactions corresponding to its own business based on the block height on its own sub-chain, thereby improving the speed of transaction processing in the blockchain network and thus improving blockchain performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0074] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0075] Figure 1 This is a schematic diagram of an application environment of a method provided by an embodiment of the present application;
[0076] Figure 2 This is a schematic diagram of the architecture of a blockchain network provided in an embodiment of the present application;
[0077] Figure 3 This is a schematic diagram of an architecture for applying a blockchain network to an electronic bill scenario, provided by an embodiment of the present application;
[0078] Figure 4This is a schematic diagram of the architecture of a blockchain consensus network provided by an embodiment of the present application;
[0079] Figure 5 This is a data processing method based on blockchain provided by an embodiment of the present application;
[0080] Figure 6 This is a data processing method based on blockchain provided by an embodiment of the present application;
[0081] Figure 7 This is a schematic diagram of adding a main chain block to the main chain provided by an embodiment of the present application;
[0082] Figure 8 This is a data processing method based on blockchain provided by an embodiment of the present application;
[0083] Figure 9 This is a schematic diagram of the structure of a blockchain-based data processing device provided in an embodiment of the present application;
[0084] Figure 10 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0085] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0086] See Figure 1 , Figure 1 This is a schematic diagram of an application environment of a method provided by an embodiment of the present application. Figure 1 As shown, the blockchain-based data processing method provided in this application can be applied to the blockchain network 100. The blockchain network includes a network composed of relevant nodes that record and query data blocks on the blockchain. Each node in the blockchain network is a blockchain node, which is a computer device that can query or record data blocks. Figure 1 As shown, blockchain network 1000 may include business network 1100, routing layer 1200, and consensus network 1300. Business nodes 1102 in business network 1100 and routing nodes 1202 in routing layer 120 are connected via a network. Routing nodes 1202 and consensus nodes 1302 in consensus network 1300 are also connected via a network. Therefore, communication between business network 1100 and consensus network 1300 requires routing nodes 1202.
[0087] The business node 1102 can specifically be a desktop terminal or mobile terminal used by the business party that generates transaction information. The mobile terminal can specifically be a smart terminal with data processing capabilities, such as a smartphone, tablet computer, laptop computer, desktop computer, smart TV, smart speaker, desktop computer, smart watch, or in-vehicle terminal, but is not limited to such. The routing node 1202 can be implemented as an independent server or a server cluster consisting of multiple servers. The consensus node 1302 in the consensus network 1300 can record the transaction information (transaction data) corresponding to the transaction generated by the business node on the blockchain. The consensus node 1302 can be implemented as an independent server or a server cluster consisting of multiple servers. Each consensus node in the consensus network 1300 can be authorized and set by an authoritative organization. For example, when the consensus network 1300 is used in an application scenario where electronic invoice data is processed, the consensus nodes in the consensus network 1300 can generally be authorized and set by a regulatory agency.
[0088] Blockchain is the carrier and organizational method for running blockchain technology. Blockchain technology (BT), also known as distributed ledger technology, is an internet database technology characterized by decentralization, openness, and transparency, allowing everyone to participate in database records. Blockchain technology is a distributed infrastructure and computing method that uses a block chain data structure to verify and store data, a distributed node consensus algorithm to generate and update data, cryptography to ensure the security of data transmission and access, and smart contracts composed of automated script code to program and operate data.
[0089] To facilitate understanding, the following will explain blockchain and its related concepts:
[0090] Blockchain is a novel application model of computer technologies, integrating distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. It primarily organizes data in chronological order and encrypts it into a ledger, rendering it tamper-proof and forgery-proof. It also enables data verification, storage, and updates. Blockchain is essentially a decentralized database, in which every node stores an identical blockchain. The blockchain network categorizes nodes into core nodes, data nodes, and light nodes. Core nodes are responsible for network-wide consensus, effectively serving as the consensus nodes within the blockchain network. The process for consensus nodes in a blockchain network to enter consensus involves a client sending transaction data to a data node or light node. This transaction data is then relayed between data nodes or light nodes within the blockchain network until a consensus node receives the transaction data. The consensus node then packages the transaction data into a block and establishes consensus with other consensus nodes.
[0091] After receiving the transaction data sent by the data node or light node, any core node can store the transaction data in the memory pool (such as the transaction pool) and update its hash tree for recording the input data; then, update the update timestamp to the time when the transaction data is received, and try different random numbers to calculate the characteristic value. When the characteristic value is obtained, it can be determined that the core node that obtains the characteristic value has grabbed the block generation right for the transaction data. The core node can store the transaction data accordingly, generate a block header and a block body, and obtain a newly generated block; then, the core node can send the newly generated block to other core nodes in the blockchain network where it is located according to the node identifiers of other core nodes (i.e., consensus nodes) in the blockchain network, and other core nodes will verify the newly generated block (i.e., reach consensus) and add the newly generated block to the blockchain stored by them after the verification is completed. Among them, each core node in the blockchain network has a corresponding node identifier, and each core node in the blockchain network can store the node identifiers of other core nodes in the blockchain network, so that the generated blocks can be broadcast to other core nodes in the blockchain network based on the node identifiers of other core nodes, so that the transaction data stored on all core nodes in the blockchain network are consistent.
[0092] To understand the architecture of the blockchain network of this application, please refer to Figure 2 , Figure 2 This is a schematic diagram of the architecture of a blockchain network provided by an embodiment of this application. Figure 2As shown, a blockchain network may include a business network 2100, a routing layer 2200, and a consensus network 2300. Business network 2100 may include business nodes 2101 (which can verify data blocks recorded by consensus nodes on the blockchain), and consensus network 2300 may include consensus nodes 2301 that record data blocks on the blockchain. Business network 2100 and consensus network 2300 may be connected via routing layer 2200. Routing nodes 2201 in routing layer 2200 can transmit data processing requests sent by business nodes 2101 to consensus nodes 2301. Routing nodes 2201 can also forward blockchain transaction information (such as execution results for transaction data) obtained from consensus nodes 2301 to business nodes 2101. Business nodes 2101 are deployed in the business network on the public network, while consensus nodes 2301, which run the blockchain consensus protocol, are deployed in a private consensus network. The two can interact through routing nodes (such as routing nodes 2201). Routing node 2201 can isolate the business network 2100 from the core consensus network 2300. In business network 2100, each business node is peer-to-peer, forming a peer-to-peer (P2P) network. The P2P protocol is an application layer protocol running on top of the Transmission Control Protocol (TCP). Business node 2101 can pass messages received from routing node 2201 to surrounding business nodes, allowing the message to propagate between each business node in the business network.
[0093] To facilitate understanding of the application scenarios of the above blockchain network, the following will take the application of blockchain network in electronic bill scenario as an example to explain the specific scenario architecture. Figure 3 , Figure 3 This is an architectural diagram of applying blockchain network to electronic bill scenarios.
[0094] When the above Figure 2 When the blockchain network shown is applied to the scenario of electronic bills, the blockchain network can record the transaction information generated during the entire circulation process of the electronic bills. Figure 3 As shown, the blockchain network may include a business network 3200, a routing layer 3400, and a consensus network 3600.
[0095] The electronic invoice circulation process can include processes such as electronic invoice application, electronic invoice issuance, electronic invoice reimbursement, and electronic invoice tax filing. The issuance of an electronic invoice can also be referred to as electronic invoice generation. Since the entire electronic invoice circulation process involves regulatory agencies, invoice issuers, reimbursers, and taxpayers, the business network 3200 may include a regulatory agency dedicated network 3201 providing regulatory services, a public cloud 3202 providing services to invoice issuers, reimbursers, and taxpayers, and a private cloud 3203 providing electronic invoice storage services for consumers. The regulatory agency dedicated network 3201 may include computer equipment used by regulatory agencies involved in electronic invoices, including regulatory agency terminals 32011. The public cloud 3202 may include computer equipment used by the issuer, reimburser, and taxpayer for electronic invoices, including an issuer terminal 32021, a reimburser terminal 32022, and a taxpayer terminal 32023. The issuer may be an invoicing service provider, the reimburser may be a reimbursement service provider, and the enterprise terminal may access the public cloud. The private cloud 3203 may include computer equipment used by users involved in electronic invoices, including a payment terminal 32031 for making payments, an electronic invoice circulation terminal 32032 for temporarily storing electronic invoices for users, and a dedicated enterprise terminal 32033. Consumer terminals may access the private cloud. The regulatory agency's private network 3201, the public cloud 3202, and the computer equipment in the private cloud 3202 may all serve as business nodes and send data upload requests or data query requests for electronic invoices to the consensus network through routing nodes.
[0096] Any routing node in the routing layer 3400 may include functional modules that provide authentication services 3401, certificate cache 3402, routing services 3403, and P2P services 3404. Authentication services 3401 can be used to authenticate business nodes in the business network, certificate cache 3402 can be used to cache the identity certificates of each business node, routing services 3403 can be used to achieve network isolation between the business network and the consensus network, and the P2P server can be used to distribute tasks between idempotent routing nodes, forming a peer-to-peer (P2P) network between routing nodes. The P2P protocol is an application layer protocol that runs on top of the TCP protocol.
[0097] Consensus network 3600 may include multiple sub-chain consensus networks 360. Each sub-chain consensus network 360 may include multiple consensus nodes 3601. These consensus nodes 3601 maintain the sub-blockchain corresponding to that sub-chain consensus network 360. For example, some sub-blockchains may be used to record transaction information related to electronic invoices within a certain invoice number range, while others may be used to record transaction information related to cancelled electronic invoices. When electronic invoice-related data needs to be recorded, the sub-blockchain to be recorded can be determined based on the permissions of the business node. The consensus branch network maintaining that sub-blockchain then records the data. Consensus nodes 3601 are typically computer devices used by regulatory agencies in various regions. Consensus nodes 3601 in each sub-chain consensus network 360 may include permission contracts, which store the transaction logic for the entire lifecycle of an electronic invoice, such as its status, transaction process, data access permissions, and e-invoice application and issuance conditions. Consensus nodes 3601 may also include caches and data blocks, which support the uploading and querying of transaction information.
[0098] It is understandable that in order to save node computing resources and improve the security of transaction data in the blockchain consensus business, this application divides the blockchain consensus network into multiple consensus sub-networks. Each consensus sub-network can be responsible for storing consensus for different businesses. Each consensus sub-network can have a blockchain corresponding to its own network (which can be called a sub-chain). Every time a block is generated, the block can be stored in the sub-chain in its own network; at the same time, the blockchain network can have a common blockchain (which can be called a main chain). Although the blocks generated by each sub-chain consensus network can be stored in the sub-chain, they still need to be linked to the main chain to facilitate unified management of all sub-chain consensus networks. In other words, the above-mentioned architecture and system flow are the basic framework of this application. On this basis, this application divides the blockchain consensus network into multiple sub-chain consensus networks. Each sub-chain consensus network can include one or more consensus nodes, that is, each sub-chain consensus network is a sub-chain consensus node cluster, and each cluster can be responsible for storing consensus for different businesses. For each new business, a sub-chain consensus node cluster can be added. For ease of understanding, please refer to Figure 4 , Figure 4 This is a schematic diagram of the architecture of a blockchain consensus network provided in an embodiment of the present application.
[0099] like Figure 4As shown, the consensus network may include sub-chain consensus network 4100, sub-chain consensus network 4200, sub-chain consensus network 4300, and sub-chain consensus network 4400. Among them, sub-chain consensus network 4100 can be responsible for credit investigation business. The transactions generated for credit investigation business will be packaged into sub-chain blocks by sub-chain consensus nodes with sub-chain block generation authority in sub-chain consensus network 4100, and then stored in sub-chain 410 after consensus of sub-chain network 4100; sub-chain consensus network 4200 can be responsible for legal person business. The transactions generated for legal person business will be packaged into sub-chain blocks by sub-chain consensus nodes with sub-chain block generation authority in sub-chain consensus network 4200, and then stored in sub-chain 420 after consensus of sub-chain network 4200. In the sub-chain consensus network 4300, transactions generated for the invoice business will be packaged into the sub-chain block by the sub-chain consensus nodes with the sub-chain block generation authority in the sub-chain consensus network 4300, and then stored in the sub-chain 430 after the sub-chain network 4300 reaches a consensus; the sub-chain consensus network 4400 can be responsible for the export business. Transactions generated for the export business will be packaged into the sub-chain block by the sub-chain consensus nodes with the sub-chain block generation authority in the sub-chain consensus network 4400, and then stored in the sub-chain 440 after the sub-chain network 4400 reaches a consensus. Figure 4 As shown, the blockchain consensus network may also include a main chain 400. In addition to being stored in their respective sub-chains, the sub-chain blocks that have passed the consensus of each sub-chain consensus network also need to be submitted to the main chain (i.e., blockchain 400). Through the main chain, the blocks of each sub-chain consensus network can be uniformly managed, thereby achieving unified management of transactions generated in the entire blockchain network. It is understandable that each sub-chain consensus network can include a representative node, and the data that each sub-chain consensus network needs to submit to the main chain can be submitted to the main chain 400 by the representative node. Figure 4 As shown, the sub-chain consensus network 4100 may include a representative node 4101, the sub-chain consensus network 4200 may include a representative node 4201, the sub-chain consensus network 4300 may include a representative node 4301, and the sub-chain consensus network 4400 may include a representative node 4401. The representative node 4101, the representative node 4201, the representative node 4301, and the representative node 4401 can be used to submit the sub-chain blocks in their own networks to the main chain 400.
[0100] In order to speed up the process of uploading subchain blocks to the main chain 400, when competing for the main chain block generation authority, the representative nodes of the subchain consensus network can hang multiple consecutive subchain blocks to a main chain block, and then upload the main chain block to the chain, thereby realizing batch uploading of subchain blocks. Among them, hanging subchain blocks to the main chain block means generating the main chain block based only on the basic information of the subchain block, so as to realize the rapid positioning of the subchain block in the subchain based on the main chain block, and thus obtain the transaction-related subchain block from the located subchain block. Among them, the basic information may include the block header information of the subchain block, the number of suspended subchain blocks, the block height of the suspended subchain block, etc. Figure 4 As shown, the main chain 400 includes a main chain block 401, a main chain block 402, a main chain block 403, and the like, wherein the main chain block 401 is suspended with sub-chain blocks A1, A2, and A3 of the sub-chain 410, which are generated when the representative node 4101 competes for the main chain block-generating authority; the main chain block 402 is suspended with sub-chain blocks C1 and C2 of the sub-chain 430, which are generated when the representative node 4301 competes for the main chain block-generating authority; the main chain block 403 is suspended with sub-chain blocks A4 and A5 of the sub-chain 410, which are generated when the representative node 4101 competes for the main chain block-generating authority again, based on the sub-chain blocks in the sub-chain 410 that have not yet been submitted to the main chain. It should be understood that the main chain blocks in the main chain 400 do not store transaction data associated with transactions generated in each sub-chain consensus network. However, based on the main chain block, the basic information of the sub-chain blocks to which it is suspended can be queried, thereby obtaining transaction data associated with transactions in the sub-chain blocks, and can also achieve unified management of transactions in the entire blockchain network. In addition, when the representative node of the sub-chain consensus network does not compete for the main chain block generation authority, the sub-chain consensus network can continue to package and generate sub-chain blocks, and reach consensus on the sub-chain blocks, and then continue to write the sub-chain blocks that have passed the consensus into the corresponding sub-chain. In addition, it should be noted that before the main chain block is added to the main chain 400, it needs to pass the consensus of the main chain consensus network. The main chain consensus network is maintained by the main chain consensus node cluster, and the representative node in the sub-chain consensus network can also belong to a main chain consensus node in the main chain consensus node cluster.
[0101] It should be understood that the blockchain network of this application can be composed of the business network, routing layer and consensus network (such as Figure 4The corresponding consensus network) is composed of a plurality of sub-chain consensus networks. In the architecture of the present application, a sub-chain consensus network can be responsible for storing consensus for a business, thereby eliminating the need for all nodes in the blockchain network to use their computing resources to participate in the block consensus of a certain business, which can save node resources. In this architecture, in order to uniformly manage each sub-chain consensus network and speed up the uplink of sub-chain blocks to the main chain, in an embodiment of the present application, a main chain block in the main chain is exclusively occupied by a sub-chain consensus network, and a main chain block represents a sub-chain block sequence suspended within a certain range, thereby realizing the batch uplink of sub-chain blocks. The specific implementation process can be found in the subsequent Figure 5 Description in the corresponding embodiment.
[0102] For easier understanding, please refer to Figure 5 , Figure 5 This is a data processing method based on blockchain provided by the embodiment of the present application. The data processing method is a method for implementing a sub-chain block sequence to be chained to the main chain in a blockchain network. The blockchain network may include a business network, a consensus network (such as Figure 4 The consensus network shown in FIG) and the routing layer for isolating the business network from the consensus network; the following method will be applied to the first representative node (which can be the above Figure 4 Any representative node in the corresponding embodiment, such as representative node 4101) is used as an example. Figure 5 As shown, the blockchain-based data processing method may include the following steps S101-S104:
[0103] Step S101: When the block production authority of the first representative node in the first sub-chain consensus network is the main chain block production authority, a sub-chain block sequence to be on-chain is obtained; each sub-chain block to be on-chain in the sub-chain block sequence belongs to the first sub-chain obtained by consensus of the first sub-chain consensus network; the main chain block production authority is obtained through bidding between the first representative node and the second representative node of the second sub-chain consensus network.
[0104] Specifically, any business in a blockchain network may be referred to as a first business. The subchain consensus node cluster responsible for consensus and uploading transaction data related to the first business may be referred to as a first subchain consensus node cluster, and the representative node in the first subchain consensus node cluster may be referred to as a first representative node. Any business in a blockchain network different from the first business may be referred to as a second business. The subchain consensus node cluster responsible for consensus and uploading transaction data related to the second business may be referred to as a second subchain consensus node cluster, and the representative node in the second subchain consensus node cluster may be referred to as a second representative node. It should be understood that each subchain consensus node cluster forms a subchain consensus network. The first subchain consensus node cluster forms the first subchain consensus network, and the second subchain consensus node cluster forms the second subchain consensus network.
[0105] Specifically, the First Representative Node belongs to the First Subchain consensus node cluster, meaning it can be any consensus node in the First Subchain consensus node cluster. The selection of the First Representative Node can be tailored to the specific circumstances and is not a limitation. As long as consensus is reached on the First Subchain consensus network, the First Representative Node can represent the First Subchain consensus network in the competition for block generation rights on the mainchain. Furthermore, the First Representative Node can serve as a block generation node for subchain blocks within the First Subchain. In this case, the First Representative Node's block generation authority is that of the subchain. The First Representative Node can package transaction data related to the First Business into subchain blocks, then complete consensus on the subchain blocks within the First Subchain consensus network and upload them to the blockchain.
[0106] Specifically, to uniformly manage all operations across the entire blockchain network, blocks generated within any subchain consensus network are not only added to the corresponding subchain for storage but also need to be attached to a mainchain block within the mainchain. Therefore, the blockchain network may include a mainchain consensus node cluster, which is responsible for consensus and uploading mainchain blocks to the mainchain. As mentioned above, the right to produce mainchain blocks will be competed for by representative nodes. In other words, representative nodes are responsible for generating mainchain blocks. Therefore, it can be understood that after a subchain consensus network selects a consensus node as a representative node, the representative node will be added to the mainchain consensus node cluster. This means that the representative node can serve as a subchain consensus node within the subchain consensus node cluster or a mainchain consensus node within the mainchain consensus node cluster. For example, after the first representative node is selected by the first subchain consensus network, it will be added to the mainchain consensus network. The first representative node can serve as the block producer for the main chain block in the main chain. In this case, the first representative node's block production authority should be the main chain block production authority. The first representative node can obtain the sub-chain block sequence to be on-chained, and then on-chain the sub-chain block sequence to the main chain, that is, suspend the sub-chain block sequence to the main chain block. When the main chain block is added to the main chain through the consensus of the main chain consensus network, it can be considered that the sub-chain block to be on-chain is on-chained to the main chain. The sub-chain block sequence to be on-chained can include one or more sub-chain blocks, all of which belong to the first sub-chain and should be consecutive sub-chain blocks in the first sub-chain.
[0107] In a feasible embodiment, the process of obtaining a sequence of sub-chain blocks to be chained can be as follows: the first representative node obtains H sub-chain blocks to be chained from the node cache; from the H sub-chain blocks to be chained, according to the generation timestamps corresponding to the H sub-chain blocks to be chained, I sub-chain blocks to be chained are obtained in sequence, and a sequence of sub-chain blocks to be chained containing I sub-chain blocks to be chained is generated. Each sub-chain block to be chained is a sub-chain block that is added to the node cache after being written to the first sub-chain; H is a positive integer; and I is a positive integer less than or equal to H. The node cache can be a piece of memory allocated by the first representative node for the sub-chain blocks to be chained in the first sub-chain that have not been submitted to the main chain, and is used to cache the sub-chain blocks to be chained that have been added to the first sub-chain but have not yet been submitted to the main chain.
[0108] In an optional embodiment, when the first representative node's block production authority is a subchain block production authority, the first representative node may receive transaction data associated with the first business sent by the business node, and then generate a target subchain block based on the transaction data, wherein the first business has an associated relationship with the first subchain consensus network. The first representative node may then send the target subchain block to the remaining nodes, wherein the remaining nodes are nodes in the first subchain consensus network other than the first representative node. The first representative node may then receive voting information returned by the remaining nodes based on the target subchain block, and determine the consensus result for the target subchain block based on the voting information; if the consensus result is a consensus-approved result, the target subchain block is added to the first subchain; at the same time, the first representative node will treat the target subchain block as a new subchain block to be on-chain, and add the new subchain block to the node cache, waiting to be submitted to the main chain. Assuming the number of remaining nodes is at least two, and the number of voting information is also at least two, the specific process for determining the consensus result for the target sub-chain block based on the voting information can be as follows: the first representative node determines the voting information indicating a passed vote among the at least two voting information as the passed voting information, and counts the number of passed voting information; obtains the number of nodes in the first sub-chain consensus network; adds the number of representative nodes to the number of passed voting information to obtain the passed number; and determines the consensus result for the target sub-chain block based on the number of nodes and the passed number. It should be understood that as long as a sub-chain block generated by other consensus nodes in the first sub-chain consensus network is written to the first sub-chain through consensus, the first representative node will also add the sub-chain block as a sub-chain block to be uploaded to the node cache.
[0109] In an optional embodiment, after the main chain block to be chained is chained to the main chain, the sub-chain block to be chained in the sub-chain block sequence to be chained is released from the node cache. The main chain block to be chained refers to the main chain block generated by the first representative node based on the sub-chain block sequence to be chained. The specific generation process can be seen in the description of step S103 below.
[0110] To facilitate understanding of the above embodiment, assume that the node cache of the first representative node contains three sub-chain blocks to be on-chained, namely, sub-chain block A1 to be on-chained, sub-chain block A2 to be on-chained, and sub-chain block A3 to be on-chained. In this case, the first representative node's block generation authority is the sub-chain block generation authority. The first representative node generates a target sub-chain block, and then the first representative node reaches a consensus on the target sub-chain block in the first sub-chain consensus network. After the consensus is passed, the target sub-chain block is written to the first sub-chain. At the same time, the first representative node adds the target sub-chain block as sub-chain block A4 to be on-chained to the node cache. At this time, the node cache contains four sub-chain blocks to be on-chained. Assuming the First Representative Node wins the bid for the right to produce blocks on the main chain, meaning it is authorized to produce blocks on the main chain, it can retrieve three pending subchain blocks from its node cache and generate a pending subchain block sequence: pending subchain block A1 → pending subchain block A2 → pending subchain block A3. The First Representative Node will then process this pending subchain block sequence to the main chain. After the pending mainchain block corresponding to the pending subchain block sequence has been uploaded to the main chain, the First Representative Node can release the pending subchain blocks in the pending subchain block sequence from its node cache, leaving the node cache with only pending subchain block A4.
[0111] Step S102: Obtain the parent hash value of the target main chain and the parent hash value of the target sub-chain.
[0112] Specifically, the target main chain parent hash value is the block hash value corresponding to the main chain block with the largest generation timestamp in the main chain. This main chain block with the largest generation timestamp is the parent block of the main chain block to be on-chained in the main chain. The target sub-chain parent hash value is the block hash value corresponding to the main chain block with the largest generation timestamp in the main chain associated with the first sub-chain in the main chain. The target sub-chain parent hash value can be used to quickly locate the main chain block associated with the first sub-chain in the main chain.
[0113] Step S103: Generate a main chain block to be chained based on the sub-chain block sequence to be chained, the target main chain parent hash value, and the target sub-chain parent hash value; the main chain block to be chained includes the block header information of each sub-chain block to be chained in the sub-chain block sequence to be chained.
[0114] Specifically, the first representative node submits the sequence of sub-chain blocks to be on-chain to the main chain, which means suspending the sequence of sub-chain blocks to be on-chain to the main chain block to be on-chain. Consensus processing of the main chain block to be on-chain is then performed in the main chain consensus network. When consensus is passed, the main chain block to be on-chain is added to the main chain. Suspending the sequence of sub-chain blocks to be on-chain to the main chain block to be on-chain means packaging the basic information of all sub-chain blocks to be on-chain in the sequence of sub-chain blocks to be on-chain into the main chain block to be on-chain, so that by querying the main chain block to be on-chain, one can jump to the corresponding sub-chain and determine any sub-chain block to be on-chain in the sequence of sub-chain blocks to be on-chain. At the same time, the parent hash value of the target main chain is added to the main chain block to be on-chained. This can determine the previous main chain block of the main chain block to be on-chained. The parent hash value of the target sub-chain is also added to the main chain block to be on-chained. This allows the parent hash value of the target sub-chain to be used to quickly locate the previous main chain block that also has a sub-chain block sequence from the same sub-chain. Through the parent hash values of the target main chain and the target sub-chain, the business SPV (Simplified Payment Verification) node can independently and synchronously obtain and verify the block data of different sub-chains.
[0115] In a feasible embodiment, the specific process of generating the main chain block to be chained according to the sub-chain block sequence to be chained, the target main chain parent hash value and the target sub-chain parent hash value can be: obtaining the block header information of each sub-chain block to be chained in the sub-chain block sequence to be chained; counting the number of blocks of the sub-chain blocks to be chained in the sub-chain block sequence to be chained as the first block number; generating the sub-chain jump information based on the first sub-chain; generating the main chain block body to be chained according to the sub-chain jump information, the block header information of each sub-chain block to be chained in the sub-chain block sequence to be chained, and the first block number; generating the main chain block header to be chained according to the target main chain parent hash value and the target sub-chain parent hash value, and generating the main chain block to be chained according to the main chain block body to be chained and the main chain block header to be chained. The main chain block to be chained generated based on this embodiment includes sub-chain jump information, the number of first blocks, the block header information of each sub-chain block to be chained, that is, the hash value of the block body of each sub-chain block to be chained, the hash value of the parent block (the previous sub-chain block of the sub-chain block to be chained in the first sub-chain), the generated timestamp, etc. Therefore, any node in the blockchain network that can query the main chain block to be chained can jump to the first sub-chain corresponding to the first representative node based on the sub-chain jump information therein, or initiate an access request for the first sub-chain to the first representative node. In addition, based on the block hash value in the block header information of the sub-chain block to be chained, the required sub-chain block to be chained can be obtained from the first sub-chain.
[0116] In a feasible embodiment, the specific process of generating a to-be-linked main chain block according to the to-be-linked sub-chain block sequence, the target main chain parent hash value, and the target sub-chain parent hash value can be as follows: obtaining the to-be-linked sub-chain block with the largest generation timestamp in the to-be-linked sub-chain block sequence as the anchor sub-chain block; generating block jump information for the anchor sub-chain block based on the block hash values of the first sub-chain and the anchor sub-chain block; determining the height difference between the block height of the anchor sub-chain block and the block height of the indirect sub-chain block, and The information and height difference are used to generate the indirect jump information corresponding to the indirect sub-chain block; the indirect sub-chain block refers to the sub-chain block to be chained in the sub-chain block sequence to be chained except the anchor sub-chain block; the main chain block body to be chained is generated according to the block header information, block jump information, block header information and indirect jump information of the anchor sub-chain block; the main chain block header to be chained is generated according to the target main chain parent hash value and the target sub-chain parent hash value, and the main chain block to be chained is generated according to the main chain block body to be chained and the main chain block header to be chained. The main chain block to be chained generated based on this embodiment includes the block header information of the anchor sub-chain block and the block jump information corresponding to the anchor sub-chain block, the block header information and indirect jump information of the indirect sub-chain block. Therefore, any node in the blockchain network that can query the main chain block to be chained can jump to the anchor sub-chain block according to the block jump information when it needs to access the anchor sub-chain block. If it needs to access the indirect sub-chain block, it can first find the corresponding anchor sub-chain block according to the indirect jump information, and then find the corresponding indirect sub-chain block according to the block height difference between the anchor sub-chain block and the indirect sub-chain block.
[0117] Step S104: Uplink the to-be-linked main chain block to the main chain.
[0118] In a feasible embodiment, the specific process of uplinking the main chain block to be chained to the main chain can be: obtaining the private key corresponding to the first representative node, signing the main chain block to be chained based on the private key corresponding to the first representative node to obtain a first digital signature; broadcasting the first digital signature and the main chain block to be chained to at least two main chain consensus nodes in the main chain consensus network, so that the at least two main chain consensus nodes respectively obtain the public key corresponding to the first representative node, and verify the first digital signature based on the public key corresponding to the first representative node to obtain a verification result, and return pre-voting information to the first representative node based on the verification result; determining a first pre-voting result based on the at least two pre-voting information, and broadcasting the first pre-voting result to at least two main chain consensus nodes; receiving second pre-voting results respectively sent by at least two main chain consensus nodes; determining a consensus result based on the first pre-voting result and at least two second pre-voting results; when the consensus result is a consensus pass result, adding the main chain block to be chained to the main chain.
[0119] Using the method provided in the embodiments of this application, the consensus network in a blockchain network can be divided into different sub-chain consensus networks and a main-chain consensus network. Each sub-chain consensus network is responsible for processing a business, and can package transactions generated for that business into sub-chain blocks, and then reach consensus on the sub-chain blocks. The sub-chain blocks that pass the consensus are added to the corresponding sub-blockchain (hereinafter referred to as the sub-chain). The sub-chain blocks added to the sub-chain need to be submitted to the main blockchain corresponding to the main-chain consensus network (hereinafter referred to as the main chain) so that by accessing the main chain, the transactions processed by each sub-chain consensus network can be queried. Each sub-chain consensus network can select a representative node to compete for the main chain's block generation authority, thereby completing the chaining of the sub-chain blocks in the corresponding sub-chain. In this application, when the block generation authority of the first representative node in the first sub-chain consensus network is the main chain block generation authority, the first representative node can obtain the sub-chain block sequence to be chained, and then obtain the target main chain parent hash value and the target sub-chain parent hash value. According to the sub-chain block sequence to be chained, the target main chain parent hash value and the target sub-chain parent hash value, it generates the main chain block to be chained, and chains the main chain block to be chained to the main chain. Among them, each sub-chain block to be chained in the sub-chain block sequence to be chained belongs to the first sub-chain obtained by consensus of the first sub-chain consensus network. Through the method provided in the embodiment of the present application, when the representative node in the sub-chain consensus network bids for the main chain block generation authority, it can generate the main chain block to be chained according to the sub-chain block sequence to be chained, thereby realizing batch processing of continuous sub-chain blocks on the chain, speeding up the speed at which sub-chain blocks are confirmed by the main chain, and alleviating cache pressure. At the same time, each sub-chain consensus network can continuously execute transactions corresponding to its own business based on the block height on its own sub-chain, thereby improving the speed of transaction processing in the blockchain network and thus improving blockchain performance.
[0120] Further, see Figure 6 , Figure 6 This is a data processing method based on blockchain provided by the embodiment of the present application. The data processing method is a method for bidding for the main chain block authority in the blockchain network. The blockchain network may include a business network, a consensus network (such as Figure 4 The consensus network shown in FIG) and the routing layer for isolating the business network from the consensus network; the following method will be applied to the first representative node (which can be the above Figure 4 Any representative node in the corresponding embodiment, such as representative node 4101) is used as an example. Figure 5 As shown, the blockchain-based data processing method may include the following steps S201-S204:
[0121] Step S201: Generate first auction information based on the first on-chain asset and the node identifier.
[0122] Specifically, the first on-chain asset refers to the asset used by the first representative node to bid for the main chain block production rights, and the node identifier is used to uniquely identify the first representative node.
[0123] In a feasible embodiment, the process of generating the first auction information based on the first on-chain asset and the node identifier can be as follows: the first representative node obtains the sub-chain block to be chained from the node cache, counts the number of blocks of the sub-chain block to be chained in the node cache as the second number of blocks; determines the first on-chain asset based on the number of sub-chain blocks to be chained and the second number of blocks in the node cache, obtains the node identifier of the first representative node, and generates the first auction information based on the node identifier and the first on-chain asset. In short, the first representative node can determine the first on-chain asset based on the number of sub-chain blocks to be chained in its own node cache (for example, the more the number of sub-chain blocks to be chained, the larger the first on-chain asset determined based on the number will be in order to quickly chain the sub-chain blocks to be chained in the node cache).
[0124] In a feasible embodiment, the process of generating the first auction information based on the first on-chain asset and the node identifier can be as follows: the first representative node obtains the sub-chain block to be chained from the node cache, determines the cache waiting time corresponding to the sub-chain block to be chained in the node cache according to the generation timestamp corresponding to the sub-chain block to be chained in the node cache; determines the first on-chain asset based on the sub-chain block to be chained in the node cache and the cache waiting time, obtains the node identifier of the first representative node, and generates the first auction information based on the node identifier and the first on-chain asset. In short, the first representative node can determine the first on-chain asset based on the cache waiting time of the sub-chain block to be chained in its own node cache (for example, the longer the cache waiting time of the sub-chain block to be chained, the larger the first on-chain asset determined based on the cache waiting time will be in order to quickly chain the sub-chain block to be chained in the node cache).
[0125] In one feasible embodiment, the process of generating the first auction information based on the first on-chain asset and the node identifier can be as follows: the first representative node obtains the sub-chain block to be on-chain from the node cache, determines the cache waiting time corresponding to the sub-chain block to be on-chain in the node cache based on the generation timestamp corresponding to the sub-chain block to be on-chain in the node cache; counts the number of cache blocks of the sub-chain block to be on-chain in the node cache, determines the first on-chain asset based on the sub-chain block to be on-chain in the node cache, the cache waiting time, and the number of cache blocks; obtains the node identifier of the first representative node, and generates the first auction information based on the node identifier and the first on-chain asset. In short, the first representative node can determine the first on-chain asset by comprehensively considering the cache waiting time of the sub-chain block to be on-chain and the number of cache blocks of the sub-chain block to be on-chain in its own node cache (e.g., assigning a first weight to the cache waiting time and a second weight to the number of cache blocks, and adjusting the size of the first on-chain asset based on the cache waiting time, the number of cache blocks, the first weight, and the second weight).
[0126] Step S202: broadcast the first auction information to the main chain consensus network, so that the main chain consensus node in the main chain consensus network returns the first auction voting information based on the first auction information and the second auction information; the second auction information is generated by the second representative node.
[0127] Specifically, the second representative node refers to the representative nodes in the main chain consensus network other than the first representative node, that is, the representative nodes corresponding to the sub-chain consensus networks other than the first sub-chain consensus network in the blockchain network. In each round of the main chain block production right auction, the representative node in each sub-chain consensus network can determine the corresponding on-chain asset based on the sub-chain blocks to be uploaded in its own node cache, and then bind the on-chain asset to the node identifier to obtain the auction information. The auction information generated by the representative node in each sub-chain consensus network is broadcast to the main chain consensus node cluster in the main chain consensus network, so that the main chain consensus node cluster can determine which representative node has the right to produce the new main chain block based on the amount of on-chain assets provided by each representative node.
[0128] Step S203: Determine second auction voting information according to the first auction information and the second auction information.
[0129] In a feasible embodiment, after the first representative node receives the second auction information sent by the second representative node, it can obtain the second on-chain asset and the node identifier of the second representative node from the second auction information. Then, the first representative node determines the larger of the first on-chain asset and the second on-chain asset as the target on-chain asset; obtains the node identifier corresponding to the target on-chain asset from the first block auction information and the second block auction information as the block-producing node identifier; generates a block-producing approval vote for the block-producing node identifier, and uses the block-producing approval vote as the second auction voting information.
[0130] Step S204: Determine the block production authority of the first representative node based on the first auction voting information and the second auction voting information.
[0131] In a feasible embodiment, when the auction voting information includes block approval votes for the node identifier of a representative node, the process of determining the block approval authority of the first representative node based on the first auction voting information and the second auction voting information can be: determining the first number of block approval votes generated for the node identifier of the first representative node and the second number of block approval votes generated for the node identifier of the second representative node from the first auction voting information and the second auction voting information; if the first number of approval votes exceeds the second number of approval votes, the block approval authority of the first representative node is determined to be the main chain block approval authority.
[0132] It should be noted that the auction process for the main-chain block production rights for the main-chain block with block height M+1 in the main-chain consensus network can be executed simultaneously with the consensus process for the main-chain block with block height M in the main-chain consensus network. Simply put, when the representative nodes in the main-chain consensus network conduct pre-voting for the main-chain block with block height M, they can include the auction information of their sub-chain consensus network when voting, that is, broadcast the pre-voting information along with the auction information. Then, during the pre-commit phase, when the pre-voting results are broadcast to other main-chain consensus nodes, the auction voting results determined based on the auction information will also be broadcast to other main-chain consensus nodes. Therefore, when the consensus result for the main-chain block with block height M is determined, the auction result for the main-chain block production rights for the main-chain block with block height M+1 is also determined.
[0133] In the embodiment of the present application, the representative nodes in different sub-chain consensus networks can generate auction assets according to their own needs. When the auction is successful, the sequence of cached blocks to be chained can be directly suspended to the main chain block of the main chain, making the auction of the main chain block's main chain block authority more flexible. At the same time, batch processing of sub-chain blocks to be chained can speed up the speed of block chaining and improve the performance of the blockchain.
[0134] To understand the specific process of the first representative node submitting the sub-chain block sequence to the data ledger (main chain), please refer to Figure 7 , Figure 7 This is a schematic diagram of adding a main chain block to the main chain provided in an embodiment of the present application.
[0135] like Figure 7 As shown, taking the subchain consensus node cluster 7100 corresponding to the credit reporting business as an example, the representative node in subchain consensus node cluster 7100 is representative node 7101. The subchain corresponding to the subchain consensus network formed by subchain consensus node cluster 7100 is subchain 710, which contains five subchain blocks: subchain block E1, subchain block E2, subchain block E3, subchain block E4, and subchain block E5. It should be understood that the subchain blocks generated by subchain consensus node cluster 7100 should include the block hash value of the previous block generated by subchain consensus node cluster 7100. For example, subchain block E2 includes the block hash value of subchain block E1. Subchain consensus node cluster 7100 constructs subchain 710 (which only contains the business chain for the credit reporting business) based on the hash value of the previous subchain block included in each subchain block. After the sub-chain block that has been agreed upon by the sub-chain consensus node cluster 7100 is written into the sub-chain 710, it will also be stored in the node cache by the representative node 7101. Subsequently, the representative node 7101 will release the sub-chain block submitted to the main chain 700 from the cache. Figure 7 As shown, sub-chain blocks E1, E2, and E3 in sub-chain 710 are suspended to main chain block 701 by representative node 7101. After main chain block 701 is written into main chain 700, representative node 7101 releases these three sub-chain blocks from the node cache. Therefore, when competing for the right to generate the next main chain block 704 of main chain 700, the node cache of representative node 7101 only contains sub-chain blocks E4 and E5.
[0136] like Figure 7As shown, main chain 700 is the central blockchain, or data ledger, within the blockchain network to which subchain consensus node cluster 7100 belongs. The blockchain network to which subchain consensus node cluster 7100 belongs may include multiple subchain consensus node clusters (not shown), but the subchain blocks generated by each subchain consensus node cluster must ultimately be submitted to main chain 700. The representative node in each subchain consensus node cluster is responsible not only for the on-chain consensus of their respective subchains, but also for participating in block auctions and on-chain consensus on main chain 700. Because it is difficult to bid for the right to produce blocks on the main chain, and to speed up the submission of subchain blocks to main chain 700, the representative nodes in a subchain consensus node cluster can suspend multiple consecutive subchain blocks onto a single main chain block. For example, when representative node 7101 batch-submits subchain blocks E4 and E5 to the main chain, representative node 7101 must first generate the auction assets. Representative node 7101 can determine the block auction asset based on the number of pending subchain blocks in its own node cache. Since the node cache only contains subchain blocks E4 and E5, representative node 7101 can determine one auction asset based on this number (2). Subsequently, representative node 7101 can compete with other representative nodes in main chain 700 for the right to produce blocks on the main chain based on this auction asset. Since representative node 7101 participates in the main chain consensus, during the voting process for the main chain consensus block 703, representative node 7101 can include the auction information of its own subchain consensus node cluster when voting. Then, during the pre-commit phase for main chain block 703, each representative node in the main chain consensus node cluster corresponding to main chain 700 can simultaneously determine the auction result for the next main chain block. In addition, it should be noted that if all representative nodes do not provide bidding information for a certain main chain block, then the main chain block can be an empty block or a main chain configuration block, etc. For example, main chain block 702, that is, during the process of the main chain consensus node cluster reaching consensus on the main chain block 701, no representative node provided bidding information, and no representative node obtained the main chain block generation authority for the main chain block 702.
[0137] For example, if representative node 7101 secures the right to generate a block on the main chain, it can query blockchain 700 and retrieve the main chain block with the highest generation timestamp as main chain block 703. It can also retrieve the main chain block with the highest generation timestamp among the main chain blocks associated with the first sub-chain as main chain block 701. The representative node can then use the block hash value of main chain block 703 as the target main chain parent hash value. Simultaneously, the representative node can use the block hash value of main chain block 701 as the target sub-chain parent hash value. The representative node can then generate main chain block 704 based on the basic information of sub-chain blocks E4 and E5, the target main chain parent hash value, and the target sub-chain parent hash value. This basic information includes the block header information of sub-chain blocks E4 and E5, the top (highest block height) block being sub-chain block E5, the range of suspended blocks being 2, and so on. In addition, during the generation of main chain block 704, representative node 7101 will add jump information to main chain block 704 so that when querying main chain 700, the corresponding sub-chain block can be quickly located based on main chain block 704. For example, main chain block 701 can add jump information for sub-chain block E3. In this case, main chain block 701 is anchored to sub-chain block E3 in sub-chain 710. When the transaction data in sub-chain block E3 needs to be retrieved, it can be directly jumped to read when the jump information in main chain block 701 is obtained. It should be understood that by jumping to the transaction data in the sub-chain block, the entire business ecosystem can be obtained through the main chain (i.e., in addition to credit reporting business, it can also include information on other businesses such as export business, legal person business, credit reporting business, etc.), which facilitates unified management and review. Finally, main chain block 704 can be added to the main chain 700 after consensus is reached by the main chain consensus node cluster.
[0138] Further, see Figure 8 , Figure 8 This is a data processing method based on blockchain provided by the embodiment of the present application. The data processing method is a method for querying transaction data in a blockchain network, which may include a business network, a consensus network (such as Figure 4 The consensus network shown in FIG) and the routing layer for isolating the business network from the consensus network; the following method will be applied to the first representative node (which can be the above Figure 4 Any representative node in the corresponding embodiment, such as representative node 4101) is used as an example. Figure 5 As shown, the blockchain-based data processing method may include the following steps S301-S304:
[0139] Step S301: Receive a transaction query request initiated by a business node for a target transaction in a second business; the second business is associated with the second sub-chain consensus network; transaction data associated with the second business is stored in the second sub-chain consensus network; the transaction query request carries the query sub-chain block hash value corresponding to the target transaction.
[0140] Step S302: Obtain the target query main chain block containing the query sub-chain block hash value from the main chain.
[0141] In a feasible embodiment, the specific process of obtaining the target query main chain block containing the query sub-chain block hash value from the main chain can be: obtaining the main chain block with the minimum generation timestamp from the main chain blocks associated with the second sub-chain from the main chain as the first query main chain block; if the query sub-chain block hash value is found in the first query main chain block, then the first query main chain block is used as the target query main chain block; if the query sub-chain block hash value is not found in the first query main chain block, then the block hash value of the first query main chain block is obtained, and the main chain block whose sub-chain parent hash value is the block hash value of the first query main chain block is obtained in the main chain as the second query main chain block; if the query sub-chain block hash value is found in the second query main chain block, then the second query main chain block is used as the target query main chain block. Assume that the main chain includes main chain block 1 [sub-chain block Y1-sub-chain block Y5], main chain block 2 [sub-chain block Z1-sub-chain block Z2], main chain block 3 [sub-chain block X1-sub-chain block X3], main chain block 4 [sub-chain block Y6-sub-chain block Y7]..., among which, main chain block 1 [sub-chain block Y1-sub-chain block Y5] means that main chain block 1 is suspended with consecutive sub-chain blocks in sub-chain Y, that is, sub-chain block Y1 to sub-chain block Y5, main chain block 2 [sub-chain block X1-sub-chain block X3 ... [Block Z1-Subchain Block Z2] means that the main chain block 2 is suspended with consecutive subchain blocks in subchain Z, namely subchain blocks Z1 to subchain block Z5. Main chain block 3 [Subchain Block X1-Subchain Block X3] means that the main chain block 3 is suspended with consecutive subchain blocks in subchain X, namely subchain blocks X1 to subchain block X3. Main chain block 4 [Subchain Block Y6-Subchain Block Y7] means that the main chain block 4 is suspended with consecutive subchain blocks in subchain Y, namely subchain blocks Y6 to subchain block Y6. Assuming that the business-associated subchain corresponding to the target transaction is subchain Y, when receiving a transaction query request for the target transaction, the first representative node first obtains the main chain block 1 from the main chain, because it is the main chain block with the smallest generation timestamp among the main chain blocks associated with subchain Y. Then, it queries the block header information of subchain blocks Y1-Y5 contained in the main chain block 1 to see if there is a subchain block with the block hash value of the query subchain block corresponding to the target transaction in its suspended subchain blocks. If the values are the same, if so, the sub-chain block will be used as the target query sub-chain block, and then according to the jump information in the query main chain block 1, the target query sub-chain block will be jumped to. If not, the first representative node will obtain the block hash value of the main chain block 1, and then continue to query the main chain to determine the main chain block with the block hash value of the main chain block 1 as the parent hash value of the sub-chain, that is, main chain block 4. In this way, through the sub-chain parent hash value, there is no need to traverse the main chain blocks 2 and 3, which can speed up the query.
[0142] Step S303: Initiate a data query request to the second representative node based on the target query main chain block, so that the second representative node returns transaction data associated with the target transaction based on the data query request.
[0143] In a feasible embodiment, a specific process of initiating a data query request to the second representative node based on the target query main chain block so that the second representative node returns the transaction data associated with the target transaction based on the data query request can be: obtaining query jump information for the hash value of the query sub-chain block in the target query main chain block; initiating a data query request carrying the query jump information to the second representative node, and the second representative node will obtain the target query sub-chain block corresponding to the hash value of the query sub-chain block according to the query jump information, obtain the transaction data associated with the target transaction from the target query sub-chain block, and send the transaction data associated with the target transaction to the first representative node.
[0144] Step S304: Send the transaction data associated with the target transaction as a transaction query result to the business node.
[0145] See Figure 9 , is a structural diagram of a data processing device based on blockchain provided in an embodiment of the present application. The data processing device can be a computer program (including program code) running on a computer device, for example, the data processing device is an application software; the device can be used to execute the corresponding steps in the data processing method provided in an embodiment of the present application. Figure 9 As shown, the data processing device 1 may include: a sequence acquisition module 101, a hash value acquisition module 102, a main chain block generation module 103 and a main chain linking module 104.
[0146] Sequence acquisition module 101 is used to obtain a sequence of subchain blocks to be on-chain when the block production authority of the first representative node in the first subchain consensus network is the main chain block production authority; each subchain block to be on-chain in the sequence belongs to the first subchain obtained by consensus in the first subchain consensus network; the main chain block production authority is obtained through bidding between the first representative node and the second representative node of the second subchain consensus network;
[0147] The hash value acquisition module 102 is configured to acquire the parent hash value of the target main chain and the parent hash value of the target sub-chain. The parent hash value of the target main chain is the block hash value corresponding to the main chain block with the largest generation timestamp in the main chain. The parent hash value of the target sub-chain is the block hash value corresponding to the main chain block with the largest generation timestamp in the main chain associated with the first sub-chain in the main chain.
[0148] The main chain block generation module 103 is used to generate a main chain block to be chained based on the sub-chain block sequence to be chained, the target main chain parent hash value, and the target sub-chain parent hash value; the main chain block to be chained includes the block header information of each sub-chain block to be chained in the sub-chain block sequence to be chained;
[0149] The main chain on-chain module 104 is used to link the main chain block to be on-chain to the main chain.
[0150] The specific implementation of the sequence acquisition module 101, the hash value acquisition module 102, the main chain block generation module 103 and the main chain on-chain module 104 can be found in the above Figure 5 The description of steps S101 to S104 in the corresponding embodiment will not be repeated here.
[0151] In one embodiment, the main chain block generation module 103 may include: a first preparation unit 1031 and a first generation unit 1032 .
[0152] The first preparation unit 1031 is used to obtain the block header information of each sub-chain block to be chained in the sub-chain block sequence to be chained;
[0153] The first preparation unit 1031 is further configured to count the number of sub-chain blocks to be chained in the sequence of sub-chain blocks to be chained, as the first block number;
[0154] The first preparation unit 1031 is further configured to generate sub-chain jump information based on the first sub-chain;
[0155] The first generation unit 1032 is used to generate a main chain block body to be chained based on the sub-chain jump information, the block header information of each sub-chain block to be chained in the sub-chain block sequence to be chained, and the number of first blocks;
[0156] The first generation unit 1032 is further configured to generate a to-be-linked main chain block header according to the target main chain parent hash value and the target sub-chain parent hash value, and to generate a to-be-linked main chain block according to the to-be-linked main chain block body and the to-be-linked main chain block header.
[0157] The specific implementation of the first preparation unit 1031 and the first generation unit 1032 can be found in the above Figure 5 The description of step S103 in the corresponding embodiment will not be repeated here.
[0158] In one embodiment, the main chain block generation module 103 may include: a second preparation unit 1033 and a second generation unit 1034 .
[0159] The second preparation unit 1033 is configured to obtain the to-be-linked sub-chain block with the largest generation timestamp in the to-be-linked sub-chain block sequence as the anchor sub-chain block;
[0160] The second preparation unit 1033 is further configured to generate block jump information for the anchor subchain block based on the block hash values of the first subchain and the anchor subchain block;
[0161] The second preparation unit 1033 is further configured to determine the difference between the block height of the anchored sub-chain block and the block height of the indirect sub-chain block, and generate indirect jump information corresponding to the indirect sub-chain block based on the block jump information and the height difference; the indirect sub-chain block refers to the sub-chain block to be added to the chain in the sequence of sub-chain blocks to be added, excluding the anchored sub-chain block;
[0162] The second generation unit 1034 is used to generate a main chain block body to be uploaded based on the block header information and block jump information of the anchor sub-chain block, the block header information and indirect jump information of the indirect sub-chain block;
[0163] The second generation unit 1034 is further configured to generate a to-be-linked main chain block header according to the target main chain parent hash value and the target sub-chain parent hash value, and to generate a to-be-linked main chain block according to the to-be-linked main chain block body and the to-be-linked main chain block header.
[0164] The specific implementation of the second preparation unit 1033 and the second generation unit 1034 can be found in the above Figure 5 The description of step S103 in the corresponding embodiment will not be repeated here.
[0165] In one embodiment, the sequence acquisition module 101 may include: a block acquisition unit 1011 and a sequence generation unit 1012 .
[0166] The block acquisition unit 1011 is used to acquire H sub-chain blocks to be added to the node cache; each sub-chain block to be added to the node cache is a sub-chain block added to the node cache after being written to the first sub-chain; H is a positive integer;
[0167] The sequence generation unit 1012 is used to sequentially obtain I to-be-linked sub-chain blocks from the H to-be-linked sub-chain blocks according to the generation timestamps corresponding to the H to-be-linked sub-chain blocks, and generate a to-be-linked sub-chain block sequence including I to-be-linked sub-chain blocks; I is a positive integer less than or equal to H.
[0168] The specific implementation of the block acquisition unit 1011 and the sequence generation unit 1012 can be found in the above Figure 5 The description of step S101 in the corresponding embodiment will not be repeated here.
[0169] In one embodiment, the blockchain-based data processing device 1 may further include: a sub-chain block generation module 105 , a sub-chain block on-chain module 106 , and a cache addition module 107 .
[0170] The subchain block generation module 105 is configured to receive transaction data associated with the first business sent by the business node and generate a target subchain block based on the transaction data; the first business is associated with the first subchain consensus network;
[0171] The subchain block on-chain module 106 is used to send the target subchain block to the remaining nodes; the remaining nodes are the nodes in the first subchain consensus network other than the first representative node;
[0172] The subchain block on-chain module 106 is further configured to receive voting information returned by the remaining nodes based on the target subchain block, and determine a consensus result for the target subchain block based on the voting information;
[0173] The sub-chain block on-chain module 106 is further configured to add the target sub-chain block to the first sub-chain when the consensus result is a consensus-passed result;
[0174] The cache adding module 107 is used to take the target sub-chain block as a new sub-chain block to be chained, and add the new sub-chain block to be chained into the node cache.
[0175] The specific implementation of the sub-chain block generation module 105, the sub-chain block chain module 106 and the cache addition module 107 can be found in the above Figure 5 The description of the optional embodiment in step S101 in the corresponding embodiment will not be repeated here.
[0176] In one embodiment, the blockchain-based data processing device 1 may further include: a cache deletion module 108.
[0177] The cache deletion module 108 is used to release the sub-chain blocks to be chained in the sub-chain block sequence to be chained from the node cache after the main chain blocks to be chained are chained to the main chain.
[0178] The specific implementation of the cache deletion module 108 can be found in the above Figure 5 The description of the optional embodiment in step S101 in the corresponding embodiment will not be repeated here.
[0179] In one embodiment, the blockchain-based data processing device 1 may further include: a first auction module 109.
[0180] The first auction module 109 is configured to obtain the sub-chain blocks to be put on the chain from the node cache, and count the number of sub-chain blocks to be put on the chain in the node cache as the second block number;
[0181] The first auction module 109 is further configured to determine the first on-chain asset based on the number of sub-chain blocks to be on-chain and the second block in the node cache, obtain the node identifier of the first representative node, and generate first auction information based on the node identifier and the first on-chain asset;
[0182] The first bidding module 109 is further configured to broadcast the first bidding information to the main chain consensus network, so that the main chain consensus nodes in the main chain consensus network return the first bidding voting information based on the first bidding information and the second bidding information; the second bidding information is generated by the second representative node;
[0183] The first auction module 109 is further configured to determine second auction voting information based on the first auction information and the second auction information;
[0184] The first auction module 109 is further configured to determine the block generation authority of the first representative node based on the first auction voting information and the second auction voting information.
[0185] The specific implementation of the first bidding module 109 can be found in the above Figure 6 The description of steps S201 to S204 in the corresponding embodiment will not be repeated here.
[0186] In one embodiment, the blockchain-based data processing device 1 may further include: a second auction module 110.
[0187] The second bidding module 110 is used to obtain the sub-chain block to be chained from the node cache, and determine the cache waiting time corresponding to the sub-chain block to be chained in the node cache according to the generation timestamp corresponding to the sub-chain block to be chained in the node cache;
[0188] The second bidding module 110 is further configured to determine the first on-chain asset based on the to-be-on-chain sub-chain blocks in the node cache and the cache waiting time, obtain the node identifier of the first representative node, and generate first bidding information based on the node identifier and the first on-chain asset;
[0189] The second bidding module 110 is further configured to broadcast the first bidding information to the main chain consensus network, so that the main chain consensus nodes in the main chain consensus network return the first bidding voting information based on the first bidding information and the second bidding information; the second bidding information is generated by the second representative node;
[0190] The second auction module 110 is further configured to determine second auction voting information based on the first auction information and the second auction information;
[0191] The second auction module 110 is further configured to determine the block generation authority of the first representative node based on the first auction voting information and the second auction voting information.
[0192] The specific implementation of the second bidding module 110 can be found in the above Figure 6 The description of steps S201 to S204 in the corresponding embodiment will not be repeated here.
[0193] In one embodiment, the main chain on-chain module 104 may include: a signature unit 1041, a consensus unit 1042 and an adding unit 1043.
[0194] The signature unit 1041 is configured to obtain a private key corresponding to the first representative node, and to sign the main chain block to be uploaded based on the private key corresponding to the first representative node to obtain a first digital signature.
[0195] Consensus unit 1042 is configured to broadcast the first digital signature and the main-chain block to be uploaded to at least two main-chain consensus nodes in the main-chain consensus network, so that the at least two main-chain consensus nodes respectively obtain the public key corresponding to the first representative node, verify the first digital signature based on the public key corresponding to the first representative node, obtain a verification result, and return pre-voting information to the first representative node based on the verification result; determine a first pre-voting result based on the at least two pieces of pre-voting information, and broadcast the first pre-voting information to the at least two main-chain consensus nodes;
[0196] The consensus unit 1042 is further configured to receive second pre-voting results respectively sent by at least two main chain consensus nodes;
[0197] The consensus unit 1042 is further configured to determine a consensus result based on the first pre-voting result and at least two second pre-voting results;
[0198] The adding unit 1043 is used to add the main chain block to be chained to the main chain when the consensus result is a consensus passing result.
[0199] The specific implementation of the signature unit 1041, the consensus unit 1042 and the addition unit 1043 can be found in the above Figure 5 The description of step S104 in the corresponding embodiment will not be repeated here.
[0200] In one embodiment, the blockchain-based data processing device 1 may further include: a query receiving module 111, a query block acquisition module 112, a data acquisition module 113 and a result returning module 114.
[0201] The query receiving module 111 is configured to receive a transaction query request initiated by a business node for a target transaction in a second business; the second business is associated with a second subchain consensus network; transaction data associated with the second business is stored in the second subchain obtained through consensus by the second subchain consensus network; the transaction query request carries the query subchain block hash value corresponding to the target transaction;
[0202] The query block acquisition module 112 is used to obtain the target query main chain block containing the query sub-chain block hash value from the main chain;
[0203] The data acquisition module 113 is configured to initiate a data query request to the second representative node based on the target query main chain block, so that the second representative node returns transaction data associated with the target transaction based on the data query request;
[0204] The result returning module 114 is configured to send the transaction data associated with the target transaction as the transaction query result to the service node.
[0205] The specific implementation of the query receiving module 111, the query block obtaining module 112, the data obtaining module 113 and the result returning module 114 can be found in the above Figure 8 The description of steps S301 to S304 in the corresponding embodiment will not be repeated here.
[0206] In one embodiment, the query block acquisition module 112 may include: a first query unit 1121 , a first block acquisition unit 1122 , a second query unit 1123 , and a second block acquisition unit 1124 .
[0207] The first query unit 1121 is configured to obtain, from the main chain, a main chain block with a minimum generation timestamp among the main chain blocks associated with the second subchain, as a first query main chain block;
[0208] The first block acquisition unit 1122 is configured to use the first query main chain block as the target query main chain block if the query sub-chain block hash value is found in the first query main chain block;
[0209] The second query unit 1123 is configured to obtain the block hash value of the first query main chain block if the query sub-chain block hash value is not found in the first query main chain block, and obtain a main chain block in the main chain whose sub-chain parent hash value is the block hash value of the first query main chain block as the second query main chain block;
[0210] The second block acquisition unit 1124 is configured to use the second query main chain block as the target query main chain block if the query sub-chain block hash value is found in the second query main chain block.
[0211] The specific implementation of the first query unit 1121, the first block acquisition unit 1122, the second query unit 1123 and the second block acquisition unit 1124 can be found in the above Figure 8 The description of step S302 in the corresponding embodiment will not be repeated here.
[0212] In one embodiment, the data acquisition module 113 may include: a jump information acquisition unit 1131 and a data query unit 1132 .
[0213] The jump information acquisition unit 1131 is used to obtain the query jump information for the query sub-chain block hash value in the target query main chain block;
[0214] The data query unit 1132 is used to initiate a data query request carrying query jump information to the second representative node, so that the second representative node obtains the target query subchain block corresponding to the query subchain block hash value according to the query jump information, obtains the transaction data associated with the target transaction from the target query subchain block, and sends the transaction data associated with the target transaction to the first representative node.
[0215] The specific implementation of the jump information acquisition unit 1131 and the data query unit 1132 can be found in the above Figure 8 The description of step S303 in the corresponding embodiment will not be repeated here.
[0216] See Figure 10 , is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. Figure 10 As shown, the computer device 1000 may include: a processor 1001, a network interface 1004 and a memory 1005. In addition, the above-mentioned computer device 1000 may also include: a user interface 1003, and at least one communication bus 1002. The communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), a keyboard (Keyboard), and the user interface 1003 may optionally include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1004 may be a high-speed RAM memory, or a non-volatile memory (non-volatile memory), such as at least one disk memory. The memory 1005 may optionally be at least one storage device located away from the aforementioned processor 1001. As Figure 10 As shown, the memory 1005 as a computer-readable storage medium may include an operating system, a network communication module, a user interface module, and a device control application.
[0217] In such Figure 10 In the computer device 1000 shown, the network interface 1004 can provide a network communication element; the user interface 1003 is mainly used to provide an interface for user input; and the processor 1001 can be used to call the device control application stored in the memory 1005 to achieve:
[0218] When the block production authority of the first representative node in the first subchain consensus network becomes the main chain block production authority, a sequence of subchain blocks to be on-chain is obtained; each subchain block to be on-chain in the sequence belongs to the first subchain reached by consensus in the first subchain consensus network; the main chain block production authority is obtained through bidding between the first representative node and the second representative node of the second subchain consensus network;
[0219] Obtain the target main chain parent hash value and the target sub-chain parent hash value; the target main chain parent hash value is the block hash value corresponding to the main chain block with the largest generation timestamp in the main chain; the target sub-chain parent hash value is the block hash value corresponding to the main chain block with the largest generation timestamp in the main chain associated with the first sub-chain in the main chain;
[0220] Generate the main chain block to be on-chain based on the sub-chain block sequence to be on-chain, the target main chain parent hash value, and the target sub-chain parent hash value; the main chain block to be on-chain includes the block header information of each sub-chain block to be on-chain in the sub-chain block sequence to be on-chain;
[0221] Upload the main chain block to be uploaded to the main chain.
[0222] It should be understood that the computer device 1000 described in the embodiment of the present application can execute the above Figure 5 、 Figure 6 、 Figure 8 The description of the blockchain-based data processing method in any corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of using the same method will not be repeated here.
[0223] In addition, it should be pointed out here that: the embodiment of the present application also provides a computer-readable storage medium, and the computer-readable storage medium stores the computer program executed by the blockchain-based data processing device 1 mentioned above, and the computer program includes program instructions. When the processor executes the program instructions, it can execute the above-mentioned Figure 5 、 Figure 6 、 Figure 8 The description of the blockchain-based data processing method described in any corresponding embodiment will not be repeated here. Furthermore, the description of the beneficial effects of the same method will not be repeated here. For technical details not disclosed in the computer-readable storage medium embodiments involved in this application, please refer to the description of the method embodiments of this application.
[0224] The computer-readable storage medium can be the blockchain-based data processing device provided in any of the aforementioned embodiments, or the internal storage unit of the computer device, such as the computer device's hard drive or memory. The computer-readable storage medium can also be an external storage device of the computer device, such as a plug-in hard drive, smart media card (SMC), secure digital (SD) card, flash card, etc. Furthermore, the computer-readable storage medium can include both the internal storage unit of the computer device and an external storage device. The computer-readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer-readable storage medium can also be used to temporarily store data that has been output or is about to be output.
[0225] In addition, it should be noted that the present application also provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the above-mentioned Figure 5 、 Figure 6 、 Figure 8 The method provided by any corresponding embodiment.
[0226] The terms "first", "second", etc. in the description, claims, and drawings of the embodiments of the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "comprising" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, apparatus, product, or device comprising a series of steps or units is not limited to the listed steps or modules, but may optionally include steps or modules not listed, or may optionally include other step units inherent to these processes, methods, apparatuses, products, or devices.
[0227] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example in terms of network elements. Whether these network elements are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel may use different methods to implement the described network elements for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0228] The above disclosure is only a preferred embodiment of the present application, and certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A data processing method based on blockchain, characterized in that: include: When the block production authority of the first representative node in the first subchain consensus network becomes the main chain block production authority, the first representative node obtains a sequence of subchain blocks to be on-chain; each subchain block to be on-chain in the sequence belongs to the first subchain obtained by consensus of the first subchain consensus network; the main chain block production authority is obtained through bidding between the first representative node and the second representative node of the second subchain consensus network; The first representative node obtains the target main chain parent hash value and the target sub-chain parent hash value; the target main chain parent hash value is the block hash value corresponding to the main chain block with the maximum generation timestamp in the main chain; The parent hash value of the target subchain is the block hash value corresponding to the main chain block with the largest generation timestamp among the main chain blocks associated with the first subchain in the main chain; The first representative node generates a main chain block to be chained based on the sub-chain block sequence to be chained, the target main chain parent hash value, and the target sub-chain parent hash value; the main chain block to be chained includes the block header information of each sub-chain block to be chained in the sub-chain block sequence to be chained; The first representative node links the to-be-linked main chain block to the main chain.
2. The method according to claim 1, characterized in that The first representative node generates a main chain block to be chained according to the sub-chain block sequence to be chained, the target main chain parent hash value, and the target sub-chain parent hash value, including: The first representative node obtains block header information of each sub-chain block to be chained in the sequence of sub-chain blocks to be chained; Counting the number of sub-chain blocks to be chained in the sequence of sub-chain blocks to be chained as the first block number; Generate subchain jump information based on the first subchain; Generate a main chain block body to be chained based on the sub-chain jump information, the block header information of each sub-chain block to be chained in the sub-chain block sequence to be chained, and the first block quantity; Generate a to-be-chained main chain block header according to the target main chain parent hash value and the target sub-chain parent hash value, and generate a to-be-chained main chain block according to the to-be-chained main chain block body and the to-be-chained main chain block header.
3. The method according to claim 1, characterized in that The first representative node generates a main chain block to be chained according to the sub-chain block sequence to be chained, the target main chain parent hash value, and the target sub-chain parent hash value, including: The first representative node obtains the to-be-linked sub-chain block with the largest generation timestamp in the to-be-linked sub-chain block sequence as the anchor sub-chain block; Generate block jump information for the anchor subchain block based on the block hash values of the first subchain and the anchor subchain block; Determining the height difference between the block height of the anchor sub-chain block and the block height of the indirect sub-chain block, and generating indirect jump information corresponding to the indirect sub-chain block according to the block jump information and the height difference; the indirect sub-chain block refers to the sub-chain block to be chained in the sequence of sub-chain blocks to be chained except the anchor sub-chain block; Generate a main chain block body to be uploaded based on the block header information of the anchored sub-chain block, the block jump information, the block header information of the indirect sub-chain block, and the indirect jump information; Generate a to-be-chained main chain block header according to the target main chain parent hash value and the target sub-chain parent hash value, and generate a to-be-chained main chain block according to the to-be-chained main chain block body and the to-be-chained main chain block header.
4. The method according to claim 1, wherein The first representative node obtains the sub-chain block sequence to be added to the chain, including: The first representative node obtains H sub-chain blocks to be on-chained from the node cache; each sub-chain block to be on-chained is a sub-chain block added to the node cache after being written to the first sub-chain; H is a positive integer; From the H to-be-linked sub-chain blocks, according to the generation timestamps corresponding to the H to-be-linked sub-chain blocks, I to-be-linked sub-chain blocks are obtained in sequence, and a to-be-linked sub-chain block sequence including the I to-be-linked sub-chain blocks is generated; I is a positive integer less than or equal to H.
5. The method according to claim 4, characterized in that Also includes: The first representative node receives transaction data associated with a first business sent by a business node, and generates a target subchain block based on the transaction data; the first business is associated with the first subchain consensus network; The first representative node sends the target sub-chain block to the remaining nodes; the remaining nodes are nodes in the first sub-chain consensus network other than the first representative node; The first representative node receives the voting information returned by the remaining nodes based on the target sub-chain block, and determines a consensus result for the target sub-chain block based on the voting information; When the consensus result is a consensus-passed result, the first representative node adds the target sub-chain block to the first sub-chain; The first representative node uses the target sub-chain block as a new sub-chain block to be chained, and adds the new sub-chain block to be chained into the node cache.
6. The method according to claim 4, characterized in that Also includes: After uplinking the to-be-linked main chain block to the main chain, the first representative node releases the to-be-linked sub-chain block in the to-be-linked sub-chain block sequence from the node cache.
7. The method according to claim 1, characterized in that Also includes: The first representative node obtains the sub-chain blocks to be chained from the node cache, and counts the number of blocks of the sub-chain to be chained in the node cache as the second block number; The first representative node determines a first on-chain asset based on the sub-chain blocks to be on-chained in the node cache and the number of the second blocks, obtains a node identifier of the first representative node, and generates first bidding information based on the node identifier and the first on-chain asset; The first representative node broadcasts the first auction information to the main chain consensus network, so that the main chain consensus nodes in the main chain consensus network return first auction voting information based on the first auction information and the second auction information; The second auction information is generated by the second representative node; The first representative node determines second auction voting information according to the first auction information and the second auction information; The first representative node determines the block production authority of the first representative node according to the first auction voting information and the second auction voting information.
8. The method according to claim 1, characterized in that Also includes: The first representative node obtains the to-be-linked sub-chain block from the node cache, and determines the cache waiting time corresponding to the to-be-linked sub-chain block in the node cache according to the generation timestamp corresponding to the to-be-linked sub-chain block in the node cache; The first representative node determines a first on-chain asset based on the to-be-on-chain sub-chain blocks in the node cache and the cache waiting time, obtains a node identifier of the first representative node, and generates first bidding information based on the node identifier and the first on-chain asset; The first representative node broadcasts the first auction information to the main chain consensus network, so that the main chain consensus nodes in the main chain consensus network return first auction voting information based on the first auction information and the second auction information; The second auction information is generated by the second representative node; The first representative node determines second auction voting information according to the first auction information and the second auction information; The first representative node determines the block production authority of the first representative node according to the first auction voting information and the second auction voting information.
9. The method according to claim 1, characterized in that The first representative node links the to-be-linked main chain block to the main chain, including: The first representative node obtains a private key corresponding to the first representative node, and signs the main chain block to be uploaded based on the private key corresponding to the first representative node to obtain a first digital signature; Broadcasting the first digital signature and the to-be-linked main-chain block to at least two main-chain consensus nodes in the main-chain consensus network, so that the at least two main-chain consensus nodes respectively obtain the public key corresponding to the first representative node, and verifying the first digital signature based on the public key corresponding to the first representative node to obtain a verification result, and returning pre-voting information to the first representative node based on the verification result; determining a first pre-voting result based on the at least two pieces of pre-voting information, and broadcasting the first pre-voting result to the at least two main-chain consensus nodes; Receiving second pre-voting results respectively sent by the at least two main chain consensus nodes; Determining a consensus result based on the first preliminary voting result and at least two second preliminary voting results; When the consensus result is a consensus passing result, the main chain block to be chained is added to the main chain.
10. The method according to claim 1, characterized in that Also includes: The first representative node receives a transaction query request initiated by a business node for a target transaction in a second business; the second business is associated with the second subchain consensus network; transaction data associated with the second business is stored in the second subchain obtained by consensus on the second subchain consensus network; the transaction query request carries a query subchain block hash value corresponding to the target transaction; The first representative node obtains the target query main chain block containing the hash value of the query sub-chain block from the main chain; The first representative node initiates a data query request to the second representative node based on the target query main chain block, so that the second representative node returns transaction data associated with the target transaction based on the data query request; The first representative node sends the transaction data associated with the target transaction as a transaction query result to the service node.
11. The method according to claim 10, characterized in that The first representative node obtains the target query main chain block containing the query sub-chain block hash value from the main chain, including: The first representative node obtains, from the main chain, a main chain block with a minimum generation timestamp among the main chain blocks associated with the second subchain as a first query main chain block; If the query sub-chain block hash value is found in the first query main chain block, the first query main chain block is used as the target query main chain block; If the query sub-chain block hash value is not found in the first query main chain block, obtain the block hash value of the first query main chain block, and obtain the main chain block in the main chain whose sub-chain parent hash value is the block hash value of the first query main chain block as the second query main chain block; If the query sub-chain block hash value is found in the second query main chain block, the second query main chain block is used as the target query main chain block.
12. The method according to claim 11, characterized in that The first representative node initiates a data query request to the second representative node based on the target query main chain block, so that the second representative node returns transaction data associated with the target transaction based on the data query request, including: The first representative node obtains query jump information for the hash value of the query sub-chain block in the target query main chain block; Initiate a data query request carrying the query jump information to the second representative node, so that the second representative node obtains the target query sub-chain block corresponding to the query sub-chain block hash value according to the query jump information, obtains the transaction data associated with the target transaction from the target query sub-chain block, and sends the transaction data associated with the target transaction to the first representative node.
13. A computer device, characterized in that: include: processor, memory, and network interface; The processor is connected to the memory and the network interface, wherein the network interface is used to provide a data communication function, the memory is used to store program code, and the processor is used to call the program code to execute the method according to any one of claims 1 to 12.
14. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded by a processor and executing the method according to any one of claims 1 to 12.
15. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the method according to any one of claims 1 to 12 can be performed.
Citation Information
Patent Citations
A commercially implementable mode of interacting across chains based on chunk chains
CN109461080A
Medical data trusted storage and management system based on block chain
CN112883028A