Transaction method and device based on alliance chain and electronic equipment
By adopting a multi-level sharded blockchain architecture in the consortium chain, it automatically identifies and directs transaction requests to the target sharded blockchain, and solves the problem of the increase in nodes in the consortium chain, resulting in reduced transaction efficiency, and achieves more efficient, secure and flexible transaction processing.
Patent Information
- Application Number
- CN202411696592.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-25
- Publication Date
- 2025-02-28
AI Technical Summary
Due to the increase in nodes in the alliance chain, the efficiency of the alliance chain processing transactions is reduced.
Using a multi-level sharded blockchain architecture, by determining the organization involved in the transaction request, the target sharded blockchain is automatically identified, and the transaction request is directed to the most suitable sharded blockchain for processing.
It improves transaction processing speed and efficiency, reduces network load and consensus delay, enhances system security and flexibility, and reduces the impact of single chain or node failures on the system.
Smart Images

Figure CN119539951A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of blockchain, and more specifically, to a transaction method, device and electronic device based on a consortium chain. Background Art
[0002] Blockchain is a distributed accounting system with decentralized and tamper-proof characteristics. It uses p2p technology and consensus algorithms to ensure that each node maintains the same data ledger. Blockchain relies on its characteristics to show more and more application prospects in industrial production, finance, people's livelihood and other aspects, and the performance of blockchain is a crucial factor in its application.
[0003] Consortium chain is a type of blockchain with an entry threshold. Only nodes with legal identities can join the blockchain. Each transaction needs to obtain signatures from various organizations according to the endorsement strategy before it can be completed. At the same time, transactions in consortium chains are characterized by aggregation. Transactions within the same organization account for the majority, followed by transactions between specific organizations, and transactions between organizations and most other organizations are relatively rare.
[0004] On the other hand, as the scale of blockchain nodes increases, the difficulty of reaching consensus in the blockchain increases, and transaction performance decreases.
[0005] With regard to the problem in related technologies that the efficiency of consortium chains in processing transactions decreases due to the increase in nodes in the consortium chains, no effective solution has been proposed so far. Summary of the invention
[0006] The main purpose of the present application is to provide a transaction method, device and electronic device based on a consortium chain to solve the problem in the related art that the efficiency of consortium chain in processing transactions is reduced due to the increase of nodes in the consortium chain.
[0007] In order to achieve the above-mentioned purpose, according to one aspect of the present application, a transaction method based on a consortium chain is provided, the method is applied to the consortium chain, the consortium chain includes a multi-level sharded blockchain, the multi-level sharded blockchain includes at least: a first sharded blockchain and a second sharded blockchain, the first sharded blockchain has a superior-subordinate relationship with at least one of the second sharded blockchains, the first sharded blockchain is the superior sharded blockchain of the second sharded blockchain, the method includes: when the second sharded blockchain receives a transaction request, determining the first transaction party and the second transaction party involved in the transaction request; determining the first organization to which the first transaction party belongs, and determining the second organization to which the second transaction party belongs, wherein the first organization and the second organization both represent the owners of the nodes in the consortium chain; determining the target sharded blockchain in the multi-level sharded blockchain according to the first organization and the second organization; and processing the transaction request through the target sharded blockchain to complete the transaction request.
[0008] Further, determining a target shard blockchain in the multi-level shard blockchain according to the first organization and the second organization includes: in the case where the first organization and the second organization represent different organizations, determining a third shard blockchain to which the first organization belongs, and determining a fourth shard blockchain to which the second organization belongs; determining a first set and a second set, wherein the first set is a set of upper-level shard blockchains of the third shard blockchain, and the second set is a set of upper-level shard blockchains of the fourth shard blockchain; determining a shard blockchain with a minimum sum of a first distance and a second distance in the third set to obtain the target shard blockchain, wherein the third set is a set of the same shard blockchains in the first set and the second set, the first distance represents the distance between the shard blockchain in the third set and the third shard blockchain, and the second distance represents the distance between the shard blockchain in the third set and the fourth shard blockchain; in the case where the first organization and the second organization represent the same organization, determining the shard blockchain corresponding to the first organization as the target shard blockchain.
[0009] Furthermore, the transaction request is processed through the target shard blockchain, including: sending the transaction request to the target shard blockchain through the second shard blockchain; verifying the transaction request through the target shard blockchain to obtain a first verification result; when the first verification result indicates that the verification is successful, packaging the transaction request through the target shard blockchain to generate a target block; performing consensus verification on the target block, and when the target block passes the consensus verification, writing the target block into each node of the target shard blockchain.
[0010] Furthermore, consensus verification is performed on the target block, and when the target block passes the consensus verification, the target block is written into each node of the target shard blockchain, including: when the target block passes the consensus verification, a target signature is calculated based on the private key of the target shard blockchain and the hash value of the target block, wherein the target signature represents the latest state of the target shard blockchain; the target signature is sent to the parent shard blockchain of the target shard blockchain; the target signature is verified by the parent shard blockchain to obtain a second verification result; when the second verification result indicates that the verification is successful, it is determined that the transaction request is successful, and the target signature is written into the ledger of the parent shard blockchain.
[0011] Furthermore, before determining the target shard blockchain in the multi-level shard blockchain based on the first organization and the second organization, the method also includes: determining the routing information of each shard blockchain in the multi-level shard blockchain, wherein the routing information of each shard blockchain includes at least: the routing information of the upper-level shard blockchain of each shard blockchain, and the routing information of the lower-level shard blockchain of each shard blockchain; before processing the transaction request through the target shard blockchain, the method also includes: determining the routing information of the second shard blockchain based on the routing information of each shard blockchain, and forwarding the transaction request to the target shard blockchain based on the routing information of the second shard blockchain.
[0012] Furthermore, after forwarding the transaction request to the target shard blockchain according to the routing information of the second shard blockchain, the method also includes: determining the transaction party of the transaction request through the target shard blockchain; when the transaction party of the transaction request belongs to the organization corresponding to the target shard blockchain, or the transaction party of the transaction request belongs to the organization corresponding to any lower-level shard blockchain of the target shard blockchain, executing the step of processing the transaction request through the target shard blockchain.
[0013] Furthermore, before determining the first organization to which the first transaction party belongs and determining the second organization to which the second transaction party belongs, the method also includes: collecting historical transaction data, wherein the historical transaction data at least includes: the node to which the transaction party of each transaction belongs and the number of transactions of each transaction party; determining a first node and a second node based on the historical transaction data, wherein the number of transactions between the first node and the second node is greater than a preset number; dividing the first node and the second node into a third organization, and building a sharded blockchain based on the third organization.
[0014] Furthermore, after determining the target shard blockchain in the multi-level shard blockchain based on the first organization and the second organization, the method also includes: determining the transaction frequency between the first organization and the second organization within a preset time period; when the transaction frequency is greater than a preset value, constructing a fifth shard blockchain, wherein the fifth shard blockchain is the upper-level shard blockchain of the first organization and the second organization; and adding the fifth shard blockchain to the multi-level shard blockchain.
[0015] In order to achieve the above-mentioned purpose, according to another aspect of the present application, a transaction device based on a consortium chain is provided, wherein the device deploys a consortium chain, wherein the consortium chain includes a multi-level sharded blockchain, wherein the multi-level sharded blockchain includes at least: a first sharded blockchain and a second sharded blockchain, wherein the first sharded blockchain has a superior-subordinate relationship with at least one of the second sharded blockchains, and the first sharded blockchain is the superior sharded blockchain of the second sharded blockchain, and the device includes: a first determination unit, configured to determine, when the second sharded blockchain receives a transaction request, a first transaction party and a second transaction party involved in the transaction request; a second determination unit, configured to determine a first organization to which the first transaction party belongs, and to determine a second organization to which the second transaction party belongs, wherein the first organization and the second organization both represent owners of nodes in the consortium chain; a third determination unit, configured to determine a target sharded blockchain in the multi-level sharded blockchain according to the first organization and the second organization; and a first processing unit, configured to process the transaction request through the target sharded blockchain to complete the transaction request.
[0016] Further, the third determination unit includes: a first determination subunit, used to determine the third shard blockchain to which the first organization belongs and the fourth shard blockchain to which the second organization belongs when the first organization and the second organization represent different organizations; a second determination subunit, used to determine a first set and a second set, wherein the first set is a set of upper-level shard blockchains of the third shard blockchain, and the second set is a set of upper-level shard blockchains of the fourth shard blockchain; a third determination subunit, used to determine the shard blockchain with the smallest sum of the first distance and the second distance in the third set, and obtain the target shard blockchain, wherein the third set is a set of the same shard blockchains in the first set and the second set, the first distance represents the distance between the shard blockchain in the third set and the third shard blockchain, and the second distance represents the distance between the shard blockchain in the third set and the fourth shard blockchain; a fourth determination subunit, used to determine the shard blockchain corresponding to the first organization as the target shard blockchain when the first organization and the second organization represent the same organization.
[0017] Furthermore, the processing unit includes: a sending subunit, used to send the transaction request to the target shard blockchain through the second shard blockchain; a verification subunit, used to verify the transaction request through the target shard blockchain to obtain a first verification result; a packaging subunit, used to package the transaction request through the target shard blockchain to generate a target block when the first verification result indicates that the verification is successful; a writing subunit, used to perform consensus verification on the target block, and when the target block passes the consensus verification, write the target block into each node of the target shard blockchain.
[0018] Furthermore, the writing subunit includes: a calculation module, which is used to calculate the target signature based on the private key of the target shard blockchain and the hash value of the target block when the target block passes the consensus verification, wherein the target signature represents the latest state of the target shard blockchain; a sending module, which is used to send the target signature to the parent shard blockchain of the target shard blockchain; a verification module, which is used to verify the target signature through the parent shard blockchain to obtain a second verification result; a determination module, which is used to determine that the transaction request is successful when the second verification result indicates that the verification is successful, and write the target signature into the ledger of the parent shard blockchain.
[0019] Furthermore, the device also includes: a fourth determination unit, used to determine the routing information of each shard blockchain in the multi-level shard blockchain before determining the target shard blockchain in the multi-level shard blockchain based on the first organization and the second organization, wherein the routing information of each shard blockchain includes at least: the routing information of the upper-level shard blockchain of each shard blockchain, and the routing information of the lower-level shard blockchain of each shard blockchain; the device also includes: a forwarding unit, used to determine the routing information of the second shard blockchain based on the routing information of each shard blockchain before processing the transaction request through the target shard blockchain, and forward the transaction request to the target shard blockchain based on the routing information of the second shard blockchain.
[0020] Furthermore, the device also includes: a fifth determination unit, used to determine the transaction party of the transaction request through the target shard blockchain after forwarding the transaction request to the target shard blockchain according to the routing information of the second shard blockchain; a second processing unit, used to execute the step of processing the transaction request through the target shard blockchain when the transaction party of the transaction request belongs to the organization corresponding to the target shard blockchain, or the transaction party of the transaction request belongs to the organization corresponding to any lower-level shard blockchain of the target shard blockchain.
[0021] Furthermore, the device also includes: a collection unit, used to collect historical transaction data before determining the first organization to which the first transaction party belongs and determining the second organization to which the second transaction party belongs, wherein the historical transaction data at least includes: the node to which the transaction party of each transaction belongs and the number of transactions of each transaction party; a sixth determination unit, used to determine the first node and the second node based on the historical transaction data, wherein the number of transactions between the first node and the second node is greater than a preset number; a first construction unit, used to divide the first node and the second node into a third organization, and construct a sharded blockchain based on the third organization.
[0022] Furthermore, the device also includes: a seventh determination unit, used to determine the transaction frequency between the first organization and the second organization within a preset time period after determining the target shard blockchain in the multi-level shard blockchain based on the first organization and the second organization; a second construction unit, used to construct a fifth shard blockchain when the transaction frequency is greater than a preset value, wherein the fifth shard blockchain is the upper-level shard blockchain of the first organization and the second organization; an adding unit, used to add the fifth shard blockchain to the multi-level shard blockchain.
[0023] In order to achieve the above-mentioned purpose, according to one aspect of the present application, a computer program product is provided, including a computer program, which, when executed by a processor, implements any one of the above-mentioned alliance chain-based transaction methods, and which, when executed by a processor, implements the steps of the alliance chain-based transaction method described in each embodiment of the present application.
[0024] In order to achieve the above-mentioned purpose, according to one aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium includes stored computer instructions, wherein when the computer instructions are executed by a processor, any one of the above-mentioned alliance chain-based transaction methods is implemented.
[0025] In order to achieve the above-mentioned purpose, according to one aspect of the present application, an electronic device is provided, including one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by one or more processors, the one or more processors implement any one of the above-mentioned alliance chain-based transaction methods.
[0026] Through the present application, the following steps are adopted: when the second shard blockchain receives a transaction request, determine the first transaction party and the second transaction party involved in the transaction request; determine the first organization to which the first transaction party belongs, and determine the second organization to which the second transaction party belongs, wherein the first organization and the second organization both represent the owners of the nodes in the alliance chain; determine the target shard blockchain in the multi-level shard blockchain based on the first organization and the second organization; process the transaction request through the target shard blockchain to complete the transaction request, thereby solving the problem in the related art that the efficiency of the alliance chain in processing transactions is reduced due to the increase of nodes in the alliance chain. By splitting a large-scale alliance chain into multiple shard blockchains, each level of shard chain can independently process transactions within the organization it covers. For cross-organization transactions, that is, the first transaction party and the second transaction party belong to different organizations, the system can automatically identify the organizational affiliation of the transaction party based on the multi-level sharding architecture, and direct the transaction request to the most appropriate upper-level shard blockchain for processing, so that cross-organization transactions can quickly reach consensus in the smallest network, avoiding broadcasting transaction requests in the entire alliance chain network, reducing unnecessary network load and consensus delays, and transactions in which both parties belong to the same organization can be quickly executed within the shard chain without cross-chain communication, significantly improving transaction processing speed and efficiency, achieving efficient processing of transaction requests, effective coordination of cross-organization transactions, enhanced system security and improved flexibility, and achieving the effect of improving alliance chain performance. At the same time, the multi-level sharding architecture reduces the impact of a single chain or node failure on the entire system by distributing transaction processing to multiple shard chains and upper-level chains. Even if a shard blockchain has a problem, the upper-level blockchain and other shard chains can still continue to operate, ensuring the stability and continuity of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0028] Figure 1 It is a flow chart of a transaction method based on alliance chain provided according to the first embodiment of the present application;
[0029] Figure 2 This is a schematic diagram of an optional transaction method based on a consortium chain provided in Example 1 of the present application. Figure 1 ;
[0030] Figure 3 This is a schematic diagram of an optional transaction method based on a consortium chain provided in Example 1 of the present application. Figure 2 ;
[0031] Figure 4is a schematic diagram of a transaction device based on an alliance chain provided according to Embodiment 2 of the present application;
[0032] Figure 5 This is a schematic diagram of a transaction electronic device based on an alliance chain provided according to Example 5 of the present application. DETAILED DESCRIPTION
[0033] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0034] It should be noted that the user information (including but not limited to user device information, user personal information, collected data, used data, generated data, processed data, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, collected information, used information, generated information, processed information, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of relevant data are in compliance with the relevant laws, regulations and standards of relevant countries and regions, necessary confidentiality measures are taken, and public order and good morals are not violated, and corresponding operation portals are provided for users to choose to authorize or refuse. For example, an interface is set between this system and relevant users or organizations. Before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or organization through the interface, and obtain relevant information after receiving the consent information fed back by the aforementioned user or organization.
[0035] It should be noted that this application provides users with corresponding operation entrances for them to choose to agree or reject the automated decision-making results; if the user chooses to reject, the expert decision-making process will be entered.
[0036] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0037] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0038] Embodiment 1
[0039] The present invention is described below in conjunction with preferred implementation steps. Figure 1 is a flow chart of a transaction method based on a consortium chain provided in Example 1 of the present application, such as Figure 1 The method is applied to a consortium chain, the consortium chain includes a multi-level shard blockchain, the multi-level shard blockchain includes at least: a first shard blockchain and a second shard blockchain, the first shard blockchain and at least one second shard blockchain have a superior-subordinate relationship, the first shard blockchain is the superior shard blockchain of the second shard blockchain, the method includes the following steps:
[0040] In the first embodiment of the present invention, the transaction method based on the alliance chain provided in the first embodiment of the present application is applied to an alliance chain that adopts a multi-level sharding technical architecture. The multi-level sharding blockchain means that within the alliance chain, the blockchain is organized into multiple levels, each level contains one or more shards (i.e., partial networks). The purpose of this architecture is to improve the performance and scalability of the entire system while maintaining the security and consistency of the alliance chain.
[0041] In the structure of a multi-level sharded blockchain, there are at least two levels of sharded blockchains (i.e., there are N levels of sharded blockchains, where N is an integer greater than or equal to 1), where the "first sharded blockchain" generally refers to a higher-level sharded blockchain, and the "second sharded blockchain" refers to a lower-level sharded blockchain of the "first sharded blockchain".
[0042] The superior-subordinate relationship represents a hierarchical relationship between the first shard blockchain and the second shard blockchain. As the superior, the first shard blockchain is responsible for processing and coordinating cross-shard transactions between all second shard blockchains belonging to the subordinates of the first shard blockchain, as well as verifying and confirming the signature records of the subordinate shards, thereby ensuring the security and consistency of the entire alliance chain.
[0043] As the superior of the second shard blockchain, the first shard blockchain bears key coordination and security verification responsibilities. It not only handles cross-shard transactions, but also verifies the status of these subordinate shard blockchains by regularly receiving signature records from the subordinate shard blockchains, ensuring that their ledgers have not been tampered with, and maintaining the integrity and trust of the entire alliance chain.
[0044] The above multi-level sharded blockchain structure enables high-volume internal transactions to be quickly processed on lower-level sharded blockchains, while cross-shard transactions, especially those involving different organizations, are processed by higher-level sharded blockchains. This design not only improves transaction efficiency, but also maintains the high standards of security and consistency of the alliance chain.
[0045] For example, in Figure 2 In the example, there are transactions between shard blockchain 1, shard blockchain 2, and shard blockchain 3, but the transaction volumes and types are different. If two users come from shard blockchain 1 and shard blockchain 2 respectively, their transactions will be considered cross-shard transactions and processed by the parent blockchain 1. Transactions within shard blockchain 1 are processed by shard blockchain 1 itself. Through this hierarchical sharding processing method, the system can efficiently handle transactions of different sizes and types, and at the same time, through the verification and evidence storage mechanism of signature records, the security and consistency of all transactions within the alliance chain are ensured.
[0046] Step S101, when the second shard blockchain receives a transaction request, determines the first transaction party and the second transaction party involved in the transaction request.
[0047] In the first embodiment, the transaction request of the transaction party to which the node in the second shard blockchain belongs is sent to the second shard blockchain. When a transaction request is sent to the second shard blockchain, the node of the second shard blockchain will first parse the transaction request and extract the transaction information, including the transaction amount involved, the account information of the transaction parties, and the transaction parties, that is, the first transaction party and the second transaction party mentioned above.
[0048] Step S102, determining a first organization to which the first transaction party belongs, and determining a second organization to which the second transaction party belongs, wherein both the first organization and the second organization represent owners of nodes in the alliance chain.
[0049] In a consortium chain, each node belongs to a specific organization, which may be companies, institutions, individual users and other entities, and they jointly participate in the construction and operation of the blockchain network. Transactions in a consortium chain are often restricted by the relationship and authority between organizations. Therefore, it is necessary to clarify the organizations to which the two parties to the transaction belong.
[0050] In the first embodiment, when a transaction request is received by a node of the second shard blockchain, the node first needs to parse the transaction request and extract the account or identification information of the first transaction party and the second transaction party involved. The node determines the first organization to which the first transaction party belongs and the second organization to which the second transaction party belongs based on the mapping relationship between the transaction party's account information and the organization node in the alliance chain.
[0051] By strictly dividing nodes into different organizations and shard chains, transactions can be executed quickly on the most relevant shard chain, reducing the complexity and latency of cross-organizational transactions while also ensuring the security and consistency of transactions, as each shard chain and parent chain has its own independent consensus mechanism and data verification process.
[0052] Step S103, determining a target shard blockchain in the multi-level shard blockchain based on the first organization and the second organization.
[0053] In the first embodiment of the present invention, in the multi-level sharding architecture of the alliance chain, when a transaction request involves two different transaction parties (a first transaction party and a second transaction party), it is necessary to determine the target sharding blockchain for processing the transaction based on the first organization to which the first transaction party belongs and the second organization to which the second transaction party belongs.
[0054] In a multi-level sharding system of a consortium chain, each shard blockchain is usually responsible for processing transactions within the organization it covers, while cross-organizational transactions may need to be processed on a higher-level shard blockchain.
[0055] For example, in Figure 2 In the scenario, if the first transaction party belongs to organization 1 corresponding to shard blockchain 1 (i.e., the first organization mentioned above), and the second transaction party belongs to organization 2 corresponding to shard blockchain 2 (i.e., the second organization mentioned above), then the transaction will be considered a cross-organization transaction and needs to be processed in the upper-level blockchain 1, because the upper-level blockchain 1 is responsible for coordinating and processing cross-organization transactions between its lower-level shard blockchains (shard blockchain 1 and shard blockchain 2). If the first transaction party and the second transaction party both belong to organization 1 corresponding to shard blockchain 1, the transaction can be completed quickly within shard blockchain 1 without being escalated to the upper-level blockchain 1 for processing.
[0056] In an optional embodiment, the structure of a multi-layer sharded blockchain can be as follows: Figure 3 As shown. Figure 3In the scenario, if the first transaction party and the second transaction party belong to the organization 1 corresponding to the shard blockchain 1 (i.e., the first organization mentioned above), the transaction will be processed in the shard blockchain 1; if the first transaction party belongs to the organization 1 corresponding to the shard blockchain 1 (i.e., the first organization mentioned above), and the second transaction party belongs to the organization 2 corresponding to the shard blockchain 2 (i.e., the second organization mentioned above), the transaction will be regarded as a cross-organization transaction and needs to be processed in the upper-level blockchain 2-1, because the upper-level blockchain 2-1 is responsible for coordinating and processing cross-organization transactions between its subordinate shard blockchains (shard blockchain 1 and shard blockchain 2); if the first transaction party belongs to the organization 1 corresponding to the shard blockchain 1 (i.e., the first organization mentioned above), and the second transaction party belongs to the organization 2 corresponding to the shard blockchain 3 (i.e., the second organization mentioned above), the transaction will be regarded as a cross-organization transaction and needs to be processed in the upper-level blockchain 3-1, because the upper-level blockchain 3-1 is responsible for coordinating and processing cross-organization transactions between its subordinate shard blockchains (shard blockchain 1 and shard blockchain 3).
[0057] Step S104: Process the transaction request through the target shard blockchain to complete the transaction request.
[0058] In the first embodiment of the present invention, after determining the target shard blockchain, the transaction request is sent to the target shard blockchain, and the transaction request is verified by the nodes in the target shard blockchain. If the verification is passed, a new block and ledger are generated according to the transaction request and added to the alliance chain.
[0059] To summarize, the alliance chain-based transaction method provided in Example 1 of the present application determines the first transaction party and the second transaction party involved in the transaction request when the second shard blockchain receives the transaction request; determines the first organization to which the first transaction party belongs, and determines the second organization to which the second transaction party belongs, wherein the first organization and the second organization both represent owners of nodes in the alliance chain; determines the target shard blockchain in the multi-level shard blockchain based on the first organization and the second organization; processes the transaction request through the target shard blockchain to complete the transaction request, thereby solving the problem in the related art that the efficiency of the alliance chain in processing transactions is reduced due to the increase of nodes in the alliance chain. By splitting a large-scale alliance chain into multiple shard blockchains, each level of shard chain can independently process transactions within the organization it covers. For cross-organization transactions, that is, the first transaction party and the second transaction party belong to different organizations, the system can automatically identify the organizational affiliation of the transaction party based on the multi-level sharding architecture, and direct the transaction request to the most appropriate upper-level shard blockchain for processing, so that cross-organization transactions can quickly reach consensus in the smallest network, avoiding broadcasting transaction requests in the entire alliance chain network, reducing unnecessary network load and consensus delays, and transactions in which both parties belong to the same organization can be quickly executed within the shard chain without cross-chain communication, significantly improving transaction processing speed and efficiency, achieving efficient processing of transaction requests, effective coordination of cross-organization transactions, enhanced system security and improved flexibility, and achieving the effect of improving alliance chain performance. At the same time, the multi-level sharding architecture reduces the impact of a single chain or node failure on the entire system by distributing transaction processing to multiple shard chains and upper-level chains. Even if a shard blockchain has a problem, the upper-level blockchain and other shard chains can still continue to operate, ensuring the stability and continuity of the system.
[0060] Optionally, in the alliance chain-based transaction method provided in Example 1 of the present application, determining the target shard blockchain in the multi-level shard blockchain according to the first organization and the second organization includes: when the first organization and the second organization represent different organizations, determining the third shard blockchain to which the first organization belongs, and determining the fourth shard blockchain to which the second organization belongs; determining a first set and a second set, wherein the first set is a set of upper-level shard blockchains of the third shard blockchain, and the second set is a set of upper-level shard blockchains of the fourth shard blockchain; determining in the third set a shard blockchain with the smallest sum of the first distance and the second distance, and obtaining the target shard blockchain, wherein the third set is a set of the same shard blockchains in the first set and the second set, the first distance represents the distance between the shard blockchain in the third set and the third shard blockchain, and the second distance represents the distance between the shard blockchain in the third set and the fourth shard blockchain; when the first organization and the second organization represent the same organization, determining the shard blockchain corresponding to the first organization as the target shard blockchain.
[0061] In the first embodiment of the present invention, when the first organization is different from the second organization (that is, the transaction request belongs to a cross-organization transaction), it is necessary to identify the shard blockchains to which the first organization and the second organization belong respectively, namely, the third shard blockchain and the fourth shard blockchain. Subsequently, the parent shard blockchains of the third shard blockchain and the fourth shard blockchain are identified respectively, and two sets are formed, the first set and the second set. The first set contains all parent shard blockchains of the third shard blockchain, and the second set contains all parent shard blockchains of the fourth shard blockchain. Next, the system compares the first set and the second set to find the same set of shard blockchains in them, namely, the third set. The shard blockchains in this set are both the parent of the third shard blockchain and the fourth shard blockchain, and therefore can coordinate transactions between the two.
[0062] In the third set, the target shard blockchain with the smallest sum of distances to the third shard blockchain and the fourth shard blockchain is further determined. The above distance can be understood as the hierarchical distance in the multi-level shard blockchain architecture, that is, the number of upper-level blockchains that must be passed from one shard blockchain to another shard blockchain. Selecting the shard blockchain with the smallest sum of distances as the target shard blockchain can minimize the processing level of cross-shard transactions, thereby improving transaction processing speed and efficiency.
[0063] In the first embodiment of the present invention, when the first organization is the same as the second organization (i.e., the transaction request belongs to a same-organization transaction), the shard blockchain corresponding to the first organization (or the second organization) is determined as the target shard blockchain for processing the transaction request. In this case, cross-organization coordination is not required, and the transaction can be directly processed and consensus can be reached on the shard blockchain within the organization.
[0064] By separating the processing logic of internal transactions and cross-organization transactions, the system can better adapt to the processing requirements of different types of transactions and optimize resource allocation and network communication. This mechanism significantly enhances the transaction processing efficiency of the multi-level sharded blockchain system, especially for cross-organization transactions, by minimizing the hierarchical distance to determine the target sharded blockchain, effectively reducing the delay and complexity of cross-chain communication. The consistency and security of the system are guaranteed because in cross-organization transactions, the selection process of the target sharded blockchain fully considers the hierarchical relationship and verification mechanism between sharded blockchains.
[0065] Optionally, in the alliance chain-based transaction method provided in Example 1 of the present application, the transaction request is processed through the target shard blockchain, including: sending the transaction request to the target shard blockchain through the second shard blockchain; verifying the transaction request through the target shard blockchain to obtain a first verification result; when the first verification result indicates that the verification is successful, packaging the transaction request through the target shard blockchain to generate a target block; performing consensus verification on the target block, and when the target block passes the consensus verification, writing the target block into each node of the target shard blockchain.
[0066] In the first embodiment, when the transaction request is received by the second shard blockchain, the best shard blockchain for processing the transaction, i.e., the target shard blockchain, is determined based on the organizations (first organization and second organization) to which the transaction parties (first transaction party and second transaction party) involved in the transaction request belong. If the first organization and the second organization are different and belong to different shard blockchains, the transaction request will be forwarded to the target shard blockchain through the preset shard routing module.
[0067] After the transaction request reaches the target shard blockchain, the nodes on the target shard blockchain will perform a series of verification operations. This includes checking the legitimacy of the transaction request (for example, whether the account balance is sufficient, whether the transaction format is correct, etc.), and confirming the organizational affiliation of the transaction party to ensure that both parties to the transaction belong to the organization that the target shard blockchain has the right to process. After the verification is successful, the first verification result will be obtained, indicating that the transaction can continue, or refusing to continue processing the transaction.
[0068] Once the transaction request is verified, the node will package this transaction request together with other pending transactions into a new block (target block). The target block contains information about multiple transaction requests, as well as the hash value of the previous block to maintain the connectivity and integrity of the blockchain. The packaged target block needs to be verified by the consensus mechanism of the target shard blockchain. The consensus mechanism ensures that all nodes agree on the content of the new block to prevent malicious behavior and data inconsistencies. If the target block is accepted by the majority of nodes in the network during the consensus verification, it will be added to the ledger of the target shard blockchain and become a permanent block on the chain. This process involves synchronizing the data of the target block to all nodes of the target shard blockchain to update their local ledgers and ensure consistency across the entire network.
[0069] Through this series of steps, the multi-level sharding blockchain system of the alliance chain ensures the efficiency and security of the entire process of transaction requests from receiving, verifying, packaging to consensus and finally writing into the ledger. Through sharding processing and hierarchical coordination, transaction verification across the entire network is avoided, network load and processing delay are reduced, and the reliability and consistency of data are strengthened through the consensus mechanism, providing a more flexible, efficient and secure transaction processing solution for the alliance chain.
[0070] Optionally, in the alliance chain-based transaction method provided in Example 1 of the present application, consensus verification is performed on the target block, and when the target block passes the consensus verification, the target block is written into each node of the target shard blockchain, including: when the target block passes the consensus verification, calculating the target signature based on the private key of the target shard blockchain and the hash value of the target block, wherein the target signature represents the latest status of the target shard blockchain; sending the target signature to the parent shard blockchain of the target shard blockchain; verifying the target signature through the parent shard blockchain to obtain a second verification result; when the second verification result indicates that the verification is successful, determining that the transaction request is successful, and writing the target signature into the ledger of the parent shard blockchain.
[0071] In the first embodiment, once the target block (containing one or more transactions) passes the consensus verification in the target shard blockchain, the private key of the target shard blockchain (a key known only to the nodes of the target shard blockchain) and the hash value of the target block (a digital summary that uniquely represents the content of the target block) are used to calculate a digital signature, namely the target signature. This target signature can prove the status of the target block on the target shard blockchain, as well as the integrity and non-tampering of the content of the block.
[0072] The generated target signature will then be sent to the direct superior shard blockchain of the target shard blockchain so that the superior shard blockchain can verify and record the state of the target shard blockchain. This is to ensure the consistency and security of the entire multi-level shard blockchain system, and any changes in the state of the lower chain need to be known and confirmed by the superior chain. After the superior shard blockchain receives the target signature, it will use the public key corresponding to the target shard blockchain (the paired key of the private key, used to verify the signature generated by the private key) to verify the signature. If the target signature and the hash value of the target block can pass the verification of the superior shard blockchain (that is, the signature is valid and the block content has not been tampered with), a second verification result of successful verification is obtained.
[0073] Once the target signature is successfully verified by the upper-level shard blockchain, the upper-level shard blockchain will confirm that the transaction request of the target block has been correctly executed and record the target signature in its ledger. This process not only confirms the validity of the transaction, but also enhances the security and immutability of the target shard blockchain's ledger through the upper-level chain's evidence storage.
[0074] This mechanism plays a vital role in the multi-level sharded blockchain system. It not only ensures that the transaction requests of each sharded blockchain are correctly processed on their respective chains, but also ensures the security and consistency of the entire alliance chain through the generation, transmission and verification of target signatures. Through the signature verification between levels, even if the scale of the sharded chain is small, the security and integrity of the ledger can be maintained through the supervision of the upper chain, thereby improving the efficiency of transaction processing while ensuring the overall security and reliability of the alliance chain.
[0075] Optionally, in the alliance chain-based transaction method provided in Example 1 of the present application, before determining the target shard blockchain in the multi-level shard blockchain based on the first organization and the second organization, the method further includes: determining the routing information of each shard blockchain in the multi-level shard blockchain, wherein the routing information of each shard blockchain includes at least: the routing information of the upper-level shard blockchain of each shard blockchain, and the routing information of the lower-level shard blockchain of each shard blockchain; before processing the transaction request through the target shard blockchain, the method further includes: determining the routing information of the second shard blockchain based on the routing information of each shard blockchain, and forwarding the transaction request to the target shard blockchain based on the routing information of the second shard blockchain.
[0076] In the first embodiment, when constructing a multi-level sharded blockchain of a consortium chain, it is necessary to determine and record the hierarchical relationship and routing information of each sharded blockchain. The routing information of each sharded blockchain should at least include the detailed information of the upper-level sharded blockchain to which it belongs, and (in the case of a lower-level sharded blockchain) the detailed information of its lower-level sharded blockchain. This information is crucial for building network connections between sharded blockchains and determining the transmission path of transaction requests.
[0077] When the second shard blockchain receives a transaction request, it will first check the organization information of the two parties in the request. If the two parties belong to different organizations, that is, when it involves a cross-shard transaction, the second shard blockchain will determine the location of the target shard blockchain based on the above routing information.
[0078] After determining the target shard blockchain, the second shard blockchain will forward the transaction request using its own stored routing information. For example, it will find and connect to the entry node of the target shard blockchain, and then send the transaction request to the entry node, and the target shard blockchain will officially start processing the transaction request.
[0079] By maintaining and updating the routing information of each shard blockchain, it is possible to ensure that transaction requests are quickly and accurately directed to the most appropriate shard blockchain, avoiding unnecessary network transmission and processing delays. At the same time, the use of routing information also reflects the flexibility and efficiency of the multi-level shard blockchain system in terms of network architecture and transaction processing mechanism, effectively supporting complex transaction scenarios across shards and organizations.
[0080] Optionally, in the alliance chain-based transaction method provided in Example 1 of the present application, after forwarding the transaction request to the target shard blockchain according to the routing information of the second shard blockchain, the above method also includes: determining the transaction party of the transaction request through the target shard blockchain; when the transaction party of the transaction request belongs to the organization corresponding to the target shard blockchain, or the transaction party of the transaction request belongs to the organization corresponding to any lower-level shard blockchain of the target shard blockchain, executing the step of processing the transaction request through the target shard blockchain.
[0081] In the first embodiment, after the target shard blockchain receives the transaction request, the target shard blockchain will check the organizational affiliation information of both parties to the transaction to determine whether it has the authority to process the transaction request. If both parties to the transaction belong to the organization corresponding to the target shard blockchain (that is, the target shard blockchain is directly responsible for processing the transactions of this organization), or one party to the transaction belongs to the target shard blockchain itself, and the other party belongs to the organization corresponding to any lower-level shard blockchain under the jurisdiction of the target shard blockchain, then the target shard blockchain will directly process the transaction request, that is, the transaction request does not need to be forwarded to a higher-level shard blockchain, and can be processed and verified within the target shard blockchain or in the hierarchy between lower-level shard blockchains.
[0082] If the two parties to the transaction belong to different organizations, and these organizations do not belong to the same shard blockchain or the subordinate shard blockchain of the target shard blockchain, then the transaction request will need to be forwarded to other shard blockchains for coordination and verification of cross-organization transactions.
[0083] By matching the organizations of the two parties to the transaction with the target sharded blockchain in a multi-level sharded blockchain system, transaction processing can be ensured to be both efficient and secure. At the same time, the hierarchical structure of the alliance chain is effectively utilized to minimize cross-chain communication and processing delays, maintaining the system's high throughput and low latency characteristics, while ensuring transaction consistency and ledger security.
[0084] Optionally, in the alliance chain-based transaction method provided in Example 1 of the present application, before determining the first organization to which the first transaction party belongs and determining the second organization to which the second transaction party belongs, the method further includes: collecting historical transaction data, wherein the historical transaction data at least includes: the node to which the transaction party of each transaction belongs and the number of transactions of each transaction party; determining the first node and the second node based on the historical transaction data, wherein the number of transactions between the first node and the second node is greater than a preset number; dividing the first node and the second node into a third organization, and building a sharded blockchain based on the third organization.
[0085] In this first embodiment, in order to build a multi-level sharded blockchain in the alliance chain, it is necessary to collect historical transaction data within a certain time range. These data at least include the node information to which the two parties in each transaction belong and the number of transactions participated by each party, aiming to identify nodes or organizations with frequent transaction activities.
[0086] The system will then analyze these historical transaction data to find the first and second nodes whose transaction times exceed the preset number. The preset number is a parameter that can be set based on system requirements and statistical analysis of transaction volume to identify node pairs with particularly high transaction frequencies. Transactions between these node pairs may be frequent and important.
[0087] Once the first and second nodes with frequent transactions are identified, these nodes (i.e. the first and second nodes mentioned above) can be re-divided into a new organization, i.e. the third organization. The purpose of this step is to centrally process transactions between these nodes and provide them with a more efficient and direct transaction environment by creating a dedicated sharded blockchain.
[0088] Finally, a new shard blockchain is constructed based on the member information of the third organization. This shard blockchain will be responsible for processing transaction requests between members of the third organization, including transactions between the first node and the second node. In this way, it can ensure that transactions between nodes with high transaction frequency are optimized in processing, reduce the need for cross-shard transactions, and thus improve the transaction processing speed and efficiency of the entire system.
[0089] By dynamically adjusting the sharding structure of the alliance chain based on the analysis of historical transaction data, transaction processing is closer to actual needs, reducing unnecessary cross-chain communication and processing delays, while maintaining the security and consistency of the system. By identifying and centrally processing transactions between nodes with frequent transactions, the multi-level sharding blockchain system of the alliance chain can better cope with complex and diverse transaction scenarios, improve transaction processing capabilities, and provide users with faster and more stable services.
[0090] Optionally, in the alliance chain-based transaction method provided in Example 1 of the present application, after determining the target shard blockchain in the multi-level shard blockchain based on the first organization and the second organization, the above method also includes: determining the transaction frequency between the first organization and the second organization within a preset time period; when the transaction frequency is greater than a preset value, constructing a fifth shard blockchain, wherein the fifth shard blockchain is the upper shard blockchain of the first organization and the second organization; and adding the fifth shard blockchain to the multi-level shard blockchain.
[0091] In the first embodiment of the present invention, the number of transactions between the first organization and the second organization can be counted in real time (i.e., within the preset time period mentioned above) to identify those pairs of organizations with particularly frequent transaction activities, because a high transaction frequency may mean that there is a closer business relationship between the two organizations, or that a large number of users conduct transactions between them.
[0092] If the analysis results show that the transaction frequency between the first organization and the second organization exceeds a preset value (for example, the preset number of times mentioned above), a new upper-level shard blockchain, namely the fifth shard blockchain, is created. The fifth shard blockchain will become the common upper-level of the shard blockchains to which the first organization and the second organization belong, which means that the fifth shard blockchain will be responsible for processing cross-shard transactions between the two organizations. The purpose of creating the fifth shard blockchain is to reduce the communication and processing overhead of cross-organization transactions between lower-level shard blockchains, and to improve transaction processing speed and overall system performance.
[0093] Once the fifth shard blockchain is built, it will be integrated into the existing multi-level shard blockchain system and become part of the multi-level shard blockchain in the alliance chain. All transaction requests related to the first organization and the second organization will now be processed through the fifth shard blockchain, and there is no need for direct transaction verification and information exchange between the lower-level shard blockchains of the first organization and the second organization. This not only simplifies the transaction processing process, but also improves the efficiency and security of the system by centrally processing cross-organization transactions.
[0094] Through such dynamic structural adjustments, the multi-level sharding blockchain system based on the alliance chain can better adapt to the ever-changing transaction patterns and business needs. By creating and optimizing new upper-level sharding blockchains, it can reduce the delay and overhead of cross-sharding transactions, improve transaction processing speed, and maintain system security and consistency. This dynamic sharding mechanism based on transaction frequency is an important manifestation of the flexibility and scalability of the multi-level sharding blockchain system.
[0095] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0096] Embodiment 2
[0097] The second embodiment of the present application also provides a transaction device based on a consortium chain. It should be noted that the transaction device based on a consortium chain in the second embodiment of the present application can be used to execute the transaction method based on a consortium chain provided in the first embodiment of the present application. The transaction device based on a consortium chain provided in the second embodiment of the present application is introduced below.
[0098] Figure 4 Schematic diagram of a transaction device based on alliance chain according to the second embodiment of the present application. The device deploys an alliance chain, which includes a multi-level sharding blockchain, which includes at least: a first sharding blockchain and a second sharding blockchain, the first sharding blockchain and at least one second sharding blockchain have a superior-subordinate relationship, and the first sharding blockchain is the superior sharding blockchain of the second sharding blockchain. Figure 4 As shown, the device includes: a first determining unit 401, a second determining unit 402, a third determining unit 403 and a first processing unit 404.
[0099] Specifically, the first determining unit 401 is used to determine the first transaction party and the second transaction party involved in the transaction request when the second shard blockchain receives the transaction request.
[0100] The second determining unit 402 is used to determine the first organization to which the first transaction party belongs, and determine the second organization to which the second transaction party belongs, wherein the first organization and the second organization both represent owners of nodes in the alliance chain.
[0101] The third determination unit 403 is used to determine the target shard blockchain in the multi-level shard blockchain according to the first organization and the second organization.
[0102] The first processing unit 404 is used to process the transaction request through the target shard blockchain to complete the transaction request.
[0103] The transaction device based on the alliance chain provided in the second embodiment of the present application determines the first transaction party and the second transaction party involved in the transaction request through the first determination unit 401 when the second shard blockchain receives the transaction request; the second determination unit 402 determines the first organization to which the first transaction party belongs, and determines the second organization to which the second transaction party belongs, wherein the first organization and the second organization both represent the owners of the nodes in the alliance chain; the third determination unit 403 determines the target shard blockchain in the multi-level shard blockchain based on the first organization and the second organization; the first processing unit 404 processes the transaction request through the target shard blockchain to complete the transaction request, thereby solving the problem in the related art that the efficiency of the alliance chain in processing transactions is reduced due to the increase of nodes in the alliance chain. By splitting a large-scale alliance chain into multiple shard blockchains, each level of shard chain can independently process transactions within the organization it covers. For cross-organization transactions, that is, the first transaction party and the second transaction party belong to different organizations, the system can automatically identify the organizational affiliation of the transaction party based on the multi-level sharding architecture, and direct the transaction request to the most appropriate upper-level shard blockchain for processing, so that cross-organization transactions can quickly reach consensus in the smallest network, avoiding broadcasting transaction requests in the entire alliance chain network, reducing unnecessary network load and consensus delays, and transactions in which both parties belong to the same organization can be quickly executed within the shard chain without cross-chain communication, significantly improving transaction processing speed and efficiency, achieving efficient processing of transaction requests, effective coordination of cross-organization transactions, enhanced system security and improved flexibility, and achieving the effect of improving alliance chain performance. At the same time, the multi-level sharding architecture reduces the impact of a single chain or node failure on the entire system by distributing transaction processing to multiple shard chains and upper-level chains. Even if a shard blockchain has a problem, the upper-level blockchain and other shard chains can still continue to operate, ensuring the stability and continuity of the system.
[0104] Optionally, in the alliance chain-based transaction device provided in Example 2 of the present application, the above-mentioned third determination unit 403 includes: a first determination subunit, which is used to determine the third shard blockchain to which the first organization belongs and the fourth shard blockchain to which the second organization belongs when the first organization and the second organization represent different organizations; a second determination subunit, which is used to determine a first set and a second set, wherein the first set is a set of upper-level shard blockchains of the third shard blockchain, and the second set is a set of upper-level shard blockchains of the fourth shard blockchain; a third determination subunit, which is used to determine the shard blockchain with the smallest sum of the first distance and the second distance in the third set, and obtain the target shard blockchain, wherein the third set is the set of the same shard blockchains in the first set and the second set, the first distance represents the distance between the shard blockchain in the third set and the third shard blockchain, and the second distance represents the distance between the shard blockchain in the third set and the fourth shard blockchain; a fourth determination subunit, which is used to determine the shard blockchain corresponding to the first organization as the target shard blockchain when the first organization and the second organization represent the same organization.
[0105] Optionally, in the alliance chain-based transaction device provided in Example 2 of the present application, the above-mentioned first processing unit 401 includes: a sending subunit, used to send the transaction request to the target shard blockchain through the second shard blockchain; a verification subunit, used to verify the transaction request through the target shard blockchain to obtain a first verification result; a packaging subunit, used to package the transaction request through the target shard blockchain to generate a target block when the first verification result indicates that the verification is successful; a writing subunit, used to perform consensus verification on the target block, and when the target block passes the consensus verification, write the target block into each node of the target shard blockchain.
[0106] Optionally, in the alliance chain-based transaction device provided in Example 2 of the present application, the above-mentioned writing sub-unit includes: a calculation module, which is used to calculate the target signature based on the private key of the target shard blockchain and the hash value of the target block when the target block passes the consensus verification, wherein the target signature represents the latest status of the target shard blockchain; a sending module, which is used to send the target signature to the parent shard blockchain of the target shard blockchain; a verification module, which is used to verify the target signature through the parent shard blockchain to obtain a second verification result; a determination module, which is used to determine that the transaction request is successful when the second verification result indicates that the verification is successful, and write the target signature into the ledger of the parent shard blockchain.
[0107] Optionally, in the alliance chain-based transaction device provided in Example 2 of the present application, the above-mentioned device also includes: a fourth determination unit, which is used to determine the routing information of each shard blockchain in the multi-level shard blockchain before determining the target shard blockchain in the multi-level shard blockchain according to the first organization and the second organization, wherein the routing information of each shard blockchain includes at least: the routing information of the upper-level shard blockchain of each shard blockchain, and the routing information of the lower-level shard blockchain of each shard blockchain; the device also includes: a forwarding unit, which is used to determine the routing information of the second shard blockchain according to the routing information of each shard blockchain before processing the transaction request through the target shard blockchain, and forward the transaction request to the target shard blockchain according to the routing information of the second shard blockchain.
[0108] Optionally, in the alliance chain-based transaction device provided in Example 2 of the present application, the above-mentioned device also includes: a fifth determination unit, used to determine the transaction party of the transaction request through the target shard blockchain after forwarding the transaction request to the target shard blockchain according to the routing information of the second shard blockchain; a second processing unit, used to execute the step of processing the transaction request through the target shard blockchain when the transaction party of the transaction request belongs to the organization corresponding to the target shard blockchain, or the transaction party of the transaction request belongs to the organization corresponding to any lower-level shard blockchain of the target shard blockchain.
[0109] Optionally, in the alliance chain-based transaction device provided in Example 2 of the present application, the above-mentioned device also includes: a collection unit, used to collect historical transaction data before determining the first organization to which the first transaction party belongs and determining the second organization to which the second transaction party belongs, wherein the historical transaction data at least includes: the node to which the transaction party of each transaction belongs and the number of transactions of each transaction party; a sixth determination unit, used to determine the first node and the second node based on the historical transaction data, wherein the number of transactions between the first node and the second node is greater than a preset number; a first construction unit, used to divide the first node and the second node into a third organization, and construct a sharded blockchain based on the third organization.
[0110] Optionally, in the alliance chain-based transaction device provided in Example 2 of the present application, the above-mentioned device also includes: a seventh determination unit, used to determine the transaction frequency between the first organization and the second organization within a preset time period after determining the target shard blockchain in the multi-level shard blockchain based on the first organization and the second organization; a second construction unit, used to construct a fifth shard blockchain when the transaction frequency is greater than a preset value, wherein the fifth shard blockchain is the upper-level shard blockchain of the first organization and the second organization; an adding unit, used to add the fifth shard blockchain to the multi-level shard blockchain.
[0111] The transaction device based on the alliance chain includes a processor and a memory. The above-mentioned first determination unit 401, second determination unit 402, third determination unit 403 and first processing unit 404 are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize corresponding functions.
[0112] The processor contains a kernel, which calls the corresponding program unit from the memory. One or more kernels can be set, and the performance of the alliance chain can be improved by adjusting the kernel parameters.
[0113] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0114] Embodiment 3 of the present invention provides a computer-readable storage medium on which a program is stored. When the program is executed by a processor, a transaction method based on a consortium chain is implemented.
[0115] Embodiment 4 of the present invention provides a processor, which is used to run a program, wherein the program executes a transaction method based on a consortium chain when running.
[0116] like Figure 5 As shown, embodiment 5 of the present invention provides an electronic device, the device includes a processor, a memory, and a program stored in the memory and executable on the processor, and the processor implements the following steps when executing the program: when the second shard blockchain receives a transaction request, determining the first transaction party and the second transaction party involved in the transaction request; determining the first organization to which the first transaction party belongs, and determining the second organization to which the second transaction party belongs, wherein the first organization and the second organization both represent owners of nodes in the alliance chain; determining a target shard blockchain in the multi-level shard blockchain based on the first organization and the second organization; and processing the transaction request through the target shard blockchain to complete the transaction request.
[0117] When the processor executes the program, the following steps are also implemented: determining a target shard blockchain in a multi-level shard blockchain according to a first organization and a second organization, including: when the first organization and the second organization represent different organizations, determining a third shard blockchain to which the first organization belongs, and determining a fourth shard blockchain to which the second organization belongs; determining a first set and a second set, wherein the first set is a set of upper-level shard blockchains of the third shard blockchain, and the second set is a set of upper-level shard blockchains of the fourth shard blockchain; determining a shard blockchain with a minimum sum of a first distance and a second distance in the third set, and obtaining a target shard blockchain, wherein the third set is a set of the same shard blockchains in the first set and the second set, the first distance represents the distance between the shard blockchain in the third set and the third shard blockchain, and the second distance represents the distance between the shard blockchain in the third set and the fourth shard blockchain; when the first organization and the second organization represent the same organization, determining the shard blockchain corresponding to the first organization as the target shard blockchain.
[0118] When the processor executes the program, the following steps are also implemented: processing the transaction request through the target shard blockchain, including: sending the transaction request to the target shard blockchain through the second shard blockchain; verifying the transaction request through the target shard blockchain to obtain a first verification result; when the first verification result indicates that the verification is successful, packaging the transaction request through the target shard blockchain to generate a target block; performing consensus verification on the target block, and when the target block passes the consensus verification, writing the target block into each node of the target shard blockchain.
[0119] When the processor executes the program, the following steps are also implemented: consensus verification is performed on the target block, and when the target block passes the consensus verification, the target block is written into each node of the target shard blockchain, including: when the target block passes the consensus verification, the target signature is calculated based on the private key of the target shard blockchain and the hash value of the target block, wherein the target signature represents the latest state of the target shard blockchain; the target signature is sent to the upper-level shard blockchain of the target shard blockchain; the target signature is verified through the upper-level shard blockchain to obtain a second verification result; when the second verification result indicates that the verification is successful, it is determined that the transaction request is successful, and the target signature is written into the account book of the upper-level shard blockchain.
[0120] When the processor executes the program, the following steps are also implemented: before determining the target shard blockchain in the multi-level shard blockchain based on the first organization and the second organization, the above method also includes: determining the routing information of each shard blockchain in the multi-level shard blockchain, wherein the routing information of each shard blockchain at least includes: the routing information of the upper-level shard blockchain of each shard blockchain, and the routing information of the lower-level shard blockchain of each shard blockchain; before processing the transaction request through the target shard blockchain, the above method also includes: determining the routing information of the second shard blockchain based on the routing information of each shard blockchain, and forwarding the transaction request to the target shard blockchain based on the routing information of the second shard blockchain.
[0121] When the processor executes the program, the following steps are also implemented: after forwarding the transaction request to the target shard blockchain according to the routing information of the second shard blockchain, the above method also includes: determining the transaction party of the transaction request through the target shard blockchain; when the transaction party of the transaction request belongs to the organization corresponding to the target shard blockchain, or the transaction party of the transaction request belongs to the organization corresponding to any lower-level shard blockchain of the target shard blockchain, the step of processing the transaction request through the target shard blockchain is executed.
[0122] When the processor executes the program, the following steps are also implemented: before determining the first organization to which the first transaction party belongs and determining the second organization to which the second transaction party belongs, the above method also includes: collecting historical transaction data, wherein the historical transaction data at least includes: the node to which the transaction party of each transaction belongs and the number of transactions of each transaction party; determining the first node and the second node based on the historical transaction data, wherein the number of transactions between the first node and the second node is greater than a preset number; dividing the first node and the second node into a third organization, and building a sharded blockchain based on the third organization.
[0123] When the processor executes the program, the following steps are also implemented: after determining the target shard blockchain in the multi-level shard blockchain based on the first organization and the second organization, the above method also includes: determining the transaction frequency between the first organization and the second organization within a preset time period; when the transaction frequency is greater than a preset value, constructing a fifth shard blockchain, wherein the fifth shard blockchain is the upper shard blockchain of the first organization and the second organization; and adding the fifth shard blockchain to the multi-level shard blockchain.
[0124] The devices in this article can be servers, PCs, PADs, mobile phones, etc.
[0125] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program that initializes the following method steps: when a second shard blockchain receives a transaction request, determining a first transaction party and a second transaction party involved in the transaction request; determining a first organization to which the first transaction party belongs, and determining a second organization to which the second transaction party belongs, wherein the first organization and the second organization both represent owners of nodes in the alliance chain; determining a target shard blockchain in a multi-level shard blockchain based on the first organization and the second organization; and processing the transaction request through the target shard blockchain to complete the transaction request.
[0126] When executed on a data processing device, it is also suitable for executing a program that is initialized with the following method steps: determining a target shard blockchain in a multi-level shard blockchain based on a first organization and a second organization, including: when the first organization and the second organization represent different organizations, determining a third shard blockchain to which the first organization belongs, and determining a fourth shard blockchain to which the second organization belongs; determining a first set and a second set, wherein the first set is a set of upper-level shard blockchains of the third shard blockchain, and the second set is a set of upper-level shard blockchains of the fourth shard blockchain; determining a shard blockchain with the smallest sum of the first distance and the second distance in the third set to obtain a target shard blockchain, wherein the third set is a set of the same shard blockchains in the first set and the second set, the first distance represents the distance between the shard blockchain in the third set and the third shard blockchain, and the second distance represents the distance between the shard blockchain in the third set and the fourth shard blockchain; when the first organization and the second organization represent the same organization, determining the shard blockchain corresponding to the first organization as the target shard blockchain.
[0127] When executed on a data processing device, it is also suitable for executing a program that is initialized with the following method steps: processing a transaction request through a target shard blockchain, including: sending the transaction request to the target shard blockchain through a second shard blockchain; verifying the transaction request through the target shard blockchain to obtain a first verification result; when the first verification result indicates that the verification is successful, packaging the transaction request through the target shard blockchain to generate a target block; performing consensus verification on the target block, and when the target block passes the consensus verification, writing the target block into each node of the target shard blockchain.
[0128] When executed on a data processing device, it is also suitable for executing a program that is initialized with the following method steps: performing consensus verification on a target block, and when the target block passes the consensus verification, writing the target block into each node of the target shard blockchain, including: when the target block passes the consensus verification, calculating a target signature based on a private key of the target shard blockchain and a hash value of the target block, wherein the target signature represents the latest state of the target shard blockchain; sending the target signature to the upper-level shard blockchain of the target shard blockchain; verifying the target signature through the upper-level shard blockchain to obtain a second verification result; when the second verification result indicates that the verification is successful, determining that the transaction request is successful, and writing the target signature into the ledger of the upper-level shard blockchain.
[0129] When executed on a data processing device, it is also suitable for executing a program that initializes the following method steps: before determining the target shard blockchain in the multi-level shard blockchain based on the first organization and the second organization, the above method also includes: determining the routing information of each shard blockchain in the multi-level shard blockchain, wherein the routing information of each shard blockchain at least includes: the routing information of the upper-level shard blockchain of each shard blockchain, and the routing information of the lower-level shard blockchain of each shard blockchain; before processing the transaction request through the target shard blockchain, the above method also includes: determining the routing information of the second shard blockchain based on the routing information of each shard blockchain, and forwarding the transaction request to the target shard blockchain based on the routing information of the second shard blockchain.
[0130] When executed on a data processing device, it is also suitable for executing a program that initializes the following method steps: after forwarding the transaction request to the target shard blockchain based on the routing information of the second shard blockchain, the above method also includes: determining the transaction party of the transaction request through the target shard blockchain; when the transaction party of the transaction request belongs to the organization corresponding to the target shard blockchain, or the transaction party of the transaction request belongs to the organization corresponding to any lower-level shard blockchain of the target shard blockchain, executing the step of processing the transaction request through the target shard blockchain.
[0131] When executed on a data processing device, it is also suitable for executing a program that initializes the following method steps: before determining the first organization to which the first transaction party belongs and determining the second organization to which the second transaction party belongs, the above method also includes: collecting historical transaction data, wherein the historical transaction data at least includes: the node to which the transaction party of each transaction belongs and the number of transactions of each transaction party; determining the first node and the second node based on the historical transaction data, wherein the number of transactions between the first node and the second node is greater than a preset number; dividing the first node and the second node into a third organization, and building a sharded blockchain based on the third organization.
[0132] When executed on a data processing device, it is also suitable for executing a program that initializes the following method steps: after determining the target shard blockchain in the multi-level shard blockchain based on the first organization and the second organization, the above method also includes: determining the transaction frequency between the first organization and the second organization within a preset time period; when the transaction frequency is greater than a preset value, constructing a fifth shard blockchain, wherein the fifth shard blockchain is the upper shard blockchain of the first organization and the second organization; and adding the fifth shard blockchain to the multi-level shard blockchain.
[0133] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0134] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0135] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0136] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0137] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0138] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0139] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0140] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0141] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0142] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A transaction method based on alliance chain, characterized in that: The method is applied to a consortium chain, the consortium chain includes a multi-level shard blockchain, the multi-level shard blockchain includes at least: a first shard blockchain and a second shard blockchain, the first shard blockchain has a superior-subordinate relationship with at least one of the second shard blockchains, the first shard blockchain is the superior shard blockchain of the second shard blockchain, and includes: When the second shard blockchain receives a transaction request, determining a first transaction party and a second transaction party involved in the transaction request; Determine a first organization to which the first transaction party belongs, and determine a second organization to which the second transaction party belongs, wherein the first organization and the second organization both represent owners of nodes in the alliance chain; Determining a target shard blockchain in the multi-level shard blockchain according to the first organization and the second organization; The transaction request is processed by the target shard blockchain to complete the transaction request.
2. The method according to claim 1, characterized in that Determining a target shard blockchain in the multi-level shard blockchain according to the first organization and the second organization includes: In the case where the first organization and the second organization represent different organizations, determining a third shard blockchain to which the first organization belongs, and determining a fourth shard blockchain to which the second organization belongs; Determine a first set and a second set, wherein the first set is a set of upper-level shard blockchains of the third shard blockchain, and the second set is a set of upper-level shard blockchains of the fourth shard blockchain; Determine in the third set a shard blockchain with the smallest sum of the first distance and the second distance, and obtain the target shard blockchain, wherein the third set is a set of the same shard blockchains in the first set and the second set, the first distance represents the distance between the shard blockchain in the third set and the third shard blockchain, and the second distance represents the distance between the shard blockchain in the third set and the fourth shard blockchain; In the case where the first organization and the second organization represent the same organization, the shard blockchain corresponding to the first organization is determined as the target shard blockchain.
3. The method according to claim 1, characterized in that: Processing the transaction request through the target shard blockchain includes: Sending the transaction request to the target shard blockchain through the second shard blockchain; Verifying the transaction request through the target shard blockchain to obtain a first verification result; When the first verification result indicates that the verification is successful, the transaction request is packaged through the target shard blockchain to generate a target block; A consensus verification is performed on the target block. If the target block passes the consensus verification, the target block is written into each node of the target shard blockchain.
4. The method according to claim 3, characterized in that Performing consensus verification on the target block, and if the target block passes the consensus verification, writing the target block into each node of the target shard blockchain, including: When the target block passes consensus verification, a target signature is calculated based on the private key of the target shard blockchain and the hash value of the target block, wherein the target signature represents the latest state of the target shard blockchain; Send the target signature to the parent shard blockchain of the target shard blockchain; Verify the target signature through the upper-level shard blockchain to obtain a second verification result; When the second verification result indicates that the verification is successful, the transaction request is determined to be successful, and the target signature is written into the ledger of the parent shard blockchain.
5. The method according to claim 1, characterized in that Before determining a target shard blockchain in the multi-level shard blockchain according to the first organization and the second organization, the method further includes: Determine the routing information of each shard blockchain in the multi-level shard blockchain, wherein the routing information of each shard blockchain includes at least: the routing information of the upper-level shard blockchain of each shard blockchain and the routing information of the lower-level shard blockchain of each shard blockchain; Before processing the transaction request through the target shard blockchain, the method also includes: determining the routing information of the second shard blockchain based on the routing information of each shard blockchain, and forwarding the transaction request to the target shard blockchain based on the routing information of the second shard blockchain.
6. The method according to claim 5, characterized in that After forwarding the transaction request to the target shard blockchain according to the routing information of the second shard blockchain, the method further includes: Determine the transaction party of the transaction request through the target shard blockchain; When the transaction party of the transaction request belongs to the organization corresponding to the target shard blockchain, or the transaction party of the transaction request belongs to the organization corresponding to any lower-level shard blockchain of the target shard blockchain, the step of processing the transaction request through the target shard blockchain is executed.
7. The method according to claim 1, characterized in that Before determining the first organization to which the first transaction party belongs and determining the second organization to which the second transaction party belongs, the method further includes: Collect historical transaction data, wherein the historical transaction data at least includes: the node to which the transaction party of each transaction belongs and the transaction times of each transaction party; Determining a first node and a second node according to the historical transaction data, wherein the number of transactions between the first node and the second node is greater than a preset number; The first node and the second node are divided into a third organization, and a sharded blockchain is constructed based on the third organization.
8. The method according to claim 1, characterized in that After determining a target shard blockchain in the multi-level shard blockchain according to the first organization and the second organization, the method further includes: determining a transaction frequency between the first organization and the second organization within a preset period of time; When the transaction frequency is greater than a preset value, constructing a fifth shard blockchain, wherein the fifth shard blockchain is the upper shard blockchain of the first organization and the second organization; Adding the fifth shard blockchain to the multi-level shard blockchain.
9. A transaction device based on alliance chain, characterized in that: The device deploys a consortium chain, the consortium chain includes a multi-level shard blockchain, the multi-level shard blockchain includes at least: a first shard blockchain and a second shard blockchain, the first shard blockchain has a superior-subordinate relationship with at least one of the second shard blockchains, the first shard blockchain is the superior shard blockchain of the second shard blockchain, and the device includes: A first determining unit, configured to determine, when the second shard blockchain receives a transaction request, a first transaction party and a second transaction party involved in the transaction request; A second determining unit, configured to determine a first organization to which the first transaction party belongs, and to determine a second organization to which the second transaction party belongs, wherein the first organization and the second organization both represent owners of nodes in the alliance chain; A third determining unit, configured to determine a target shard blockchain in the multi-level shard blockchain according to the first organization and the second organization; The first processing unit is used to process the transaction request through the target shard blockchain to complete the transaction request.
10. An electronic device, characterized in that: It includes one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the alliance chain-based transaction method described in any one of claims 1 to 8.
