Blockchain message distribution method and device
By forming a network access layer in the node device, obtaining network identification collection and distributing blockchain messages, the problem of node devices in the blockchain network need to configure resources separately, realizing resource sharing and efficient distribution, and improving network stability Sex and management efficiency.
Patent Information
- Application Number
- CN202111406519.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-02
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2041-06-02
AI Technical Summary
In the blockchain network, when node devices participate in multiple blockchain networks, different IP addresses and port numbers need to be configured separately, resulting in excessive network resource usage, low management efficiency, and difficult to adjust configuration errors, affecting the network. Stability and scalability.
By forming a network access layer in the node device, obtaining a collection of network identifications, determining the target network of blockchain messages based on the collection, achieving efficient distribution of blockchain messages, and allowing multiple blockchain networks to share the same network resources.
The blockchain network resource allocation process is simplified, the configuration difficulty is reduced, the message distribution efficiency is improved, the network resource occupation is reduced, and network stability and management efficiency are improved.
Smart Images

Figure CN113923227B_ABST
Abstract
Description
Technical Field
[0001] One or more embodiments of this specification relate to the field of blockchain technology, and in particular, to a method and device for distributing blockchain messages. Background Art
[0002] Blockchain technology is built on top of a transmission network (e.g., a peer-to-peer network). Blockchain nodes in the transmission network use chain data structures to verify and store data, and use distributed node consensus algorithms to generate and update data. In some blockchain networks, some nodes sometimes need to implement small-scale transactions to prevent other nodes from obtaining these transactions and related data. In this case, the same node device can participate in the formation of multiple blockchain networks, that is, multiple nodes belonging to different blockchain networks are deployed in the same node device.
[0003] In related technologies, it is usually necessary to configure different IP addresses, port numbers and other network resources for multiple blockchain networks formed by the same node device. Accordingly, the sender can send blockchain messages to the nodes belonging to a certain blockchain network deployed on the node device according to the above configuration. Summary of the invention
[0004] In view of this, one or more embodiments of the present specification provide a method and device for distributing blockchain messages.
[0005] To achieve the above objectives, one or more embodiments of this specification provide the following technical solutions:
[0006] According to a first aspect of one or more embodiments of this specification, a method for distributing blockchain messages is proposed, which is applied to a node device running a blockchain platform code, wherein the blockchain platform code forms a network access layer and node instances respectively belonging to each blockchain network in the node device, and each node instance in the node device shares the network resources corresponding to the network access layer, and the method includes:
[0007] The network access layer obtains a network identification set, where the network identification set is used to record the network identifications of the blockchain networks to which the node instances deployed in the node devices belong respectively;
[0008] When the network access layer receives a blockchain message, it determines the target blockchain network corresponding to the blockchain message based on the network identifier set, and distributes the blockchain message to the target node instance belonging to the target blockchain network deployed on the node device.
[0009] According to a second aspect of one or more embodiments of the present specification, a blockchain message distribution device is proposed, which is applied to a node device running a blockchain platform code, wherein the blockchain platform code forms a network access layer and node instances respectively belonging to each blockchain network in the node device, and each node instance in the node device shares the network resources corresponding to the network access layer, and the device includes:
[0010] A set acquisition unit enables the network access layer to acquire a network identification set, where the network identification set is used to record the network identifications of the blockchain networks to which the node instances deployed in the node devices respectively belong;
[0011] The message distribution unit enables the network access layer to determine the target blockchain network corresponding to the blockchain message according to the network identification set when receiving the blockchain message, and distribute the blockchain message to the target node instance belonging to the target blockchain network deployed on the node device.
[0012] According to a third aspect of one or more embodiments of this specification, an electronic device is provided, including:
[0013] processor;
[0014] a memory for storing processor-executable instructions;
[0015] The processor implements the method as described in the first aspect by running the executable instructions.
[0016] According to a fourth aspect of one or more embodiments of the present specification, a computer-readable storage medium is provided, on which computer instructions are stored, and when the instructions are executed by a processor, the steps of the method described in the first aspect are implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 It is a schematic diagram of creating a smart contract provided by an exemplary embodiment.
[0018] Figure 2 This is a schematic diagram of calling a smart contract provided by an exemplary embodiment.
[0019] Figure 3 It is a schematic diagram of creating and calling a smart contract provided by an exemplary embodiment.
[0020] Figure 4 It is a flowchart of a blockchain message distribution method provided by an exemplary embodiment.
[0021] Figure 5 It is a schematic diagram based on a blockchain network provided by an exemplary embodiment.
[0022] Figure 6 This is a schematic diagram of the internal structure of a node device provided by an exemplary embodiment.
[0023] Figure 7 It is a structural schematic diagram of a device provided by an exemplary embodiment.
[0024] Figure 8 It is a block diagram of a blockchain message distribution device provided by an exemplary embodiment. DETAILED DESCRIPTION
[0025] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of this specification. Instead, they are merely examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.
[0026] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may be combined into a single step for description in other embodiments.
[0027] Blockchain is generally divided into three types: public blockchain, private blockchain and consortium blockchain. In addition, there are many types of combinations, such as private blockchain + consortium blockchain, consortium blockchain + public blockchain and other different combinations. Among them, the public chain has the highest degree of decentralization. Participants who join the public chain can read the data records on the chain and compete for the right to record new blocks. Moreover, each participant (i.e. node) can freely join and exit the network and perform related operations. On the contrary, the private chain has the write permission of the network controlled by a certain organization or institution, and the data reading permission is stipulated by the organization. In simple terms, the private chain can be a weakly centralized system with strictly limited and few participating nodes. This type of blockchain is more suitable for use within a specific organization. The consortium chain is a blockchain between the public chain and the private chain, which can achieve "partial decentralization". Each node in the consortium chain usually has a corresponding entity or organization; participants join the network through authorization and form a stakeholder alliance to jointly maintain the operation of the blockchain.
[0028] Whether it is a public chain, a private chain or a consortium chain, it may provide the function of smart contracts. Smart contracts on the blockchain are contracts that can be triggered and executed by transactions on the blockchain system. Smart contracts can be defined in the form of code.
[0029] Taking Ethereum as an example, it supports users to create and call some complex logic in the Ethereum network. The core of Ethereum as a programmable blockchain is the Ethereum Virtual Machine (EVM), and each Ethereum node can run EVM. EVM is a Turing-complete virtual machine, which means that various complex logics can be implemented through it. Users publish and call smart contracts in Ethereum on EVM. In fact, the virtual machine directly runs the virtual machine code (virtual machine bytecode, hereinafter referred to as "bytecode"). Smart contracts deployed on the blockchain can be in the form of bytecode.
[0030] For example Figure 1 As shown in the figure, after Bob sends a transaction containing information about creating a smart contract to the Ethereum network, the EVM of node 1 can execute this transaction and generate the corresponding contract instance. Figure 1 The "0x6f8ae93..." in the transaction represents the address of this contract. The data field of the transaction can store bytecode, and the to field of the transaction is empty. After the nodes reach an agreement through the consensus mechanism, the contract is successfully created and can be called in the subsequent process. After the contract is created, a contract account corresponding to the smart contract appears on the blockchain and has a specific address. The contract code will be saved in the contract account. The behavior of the smart contract is controlled by the contract code. In other words, the smart contract generates a virtual account on the blockchain that contains the contract code and account storage.
[0031] like Figure 2 As shown in the figure, still taking Ethereum as an example, after Bob sends a transaction for calling a smart contract to the Ethereum network, the EVM of a certain node can execute this transaction and generate a corresponding contract instance. Figure 2 The from field of the transaction is the address of the account of the transaction initiator (i.e. Bob), and the "0x6f8ae93..." in the to field represents the address of the smart contract being called. After calling the smart contract, the value of balance may change. Later, a client can Figure 2 Node 6) in the blockchain network to check the current value of balance. Smart contracts are executed independently on each node in the blockchain network in a prescribed manner, and all execution records and data are stored on the blockchain. Therefore, when the transaction is completed, the blockchain stores transaction credentials that cannot be tampered with or lost.
[0032] The schematic diagram of creating and calling smart contracts is as follows: Figure 3 To create a smart contract in Ethereum, you need to go through the process of writing the smart contract, compiling it into bytecode, and deploying it to the blockchain. To call a smart contract in Ethereum is to initiate a transaction pointing to the smart contract address. The smart contract code runs in a distributed manner in the virtual machines of each node in the Ethereum network.
[0033] It should be noted that in addition to being able to be created by users, smart contracts can also be set by the system in the genesis block. This type of contract is generally called a genesis contract. Generally, some blockchain network data structures, parameters, properties, and methods can be set in the genesis contract. In addition, accounts with system administrator privileges can create system-level contracts or modify system-level contracts (referred to as system contracts). In addition to the EVM in Ethereum, different blockchain networks may also use various virtual machines, which are not limited here.
[0034] After executing a transaction that calls a smart contract, a node in the blockchain network will generate a corresponding receipt to record information related to the execution of the smart contract. In this way, you can query the transaction receipt to obtain relevant information about the contract execution result. The contract execution result can be expressed as an event in the receipt. The message mechanism can realize message transmission through the event in the receipt to trigger the blockchain node to perform corresponding processing. The structure of the event can be, for example:
[0035] Event:
[0036] [topic][data]
[0037] [topic][data] ......
[0039] In the above example, the number of events can be one or more, wherein each event includes fields such as topic and data. The blockchain node can monitor the topic of the event, and when a predefined topic is monitored, perform a preset process, or read relevant content from the data field of the corresponding event, and perform a preset process based on the read content.
[0040] In the above event mechanism, it is equivalent to having a client with a monitoring function at the listening party (such as a user with a monitoring demand), such as running an SDK for implementing the monitoring function on the client, and the client monitors the events generated by the blockchain node, and the blockchain node only needs to generate receipts normally. In addition to the above event mechanism, the disclosure of transaction information can also be achieved in other ways. For example, the listening code can be embedded in the blockchain platform code running on the blockchain node, so that the listening code can monitor one or more data such as the transaction content of the blockchain transaction, the contract status of the smart contract, and the receipt generated by the contract, and send the monitored data to the predefined listening party. Since the listening code is deployed in the blockchain platform code, rather than at the client of the listening party, this implementation method based on the listening code is relatively more active than the event mechanism. Among them, the above listening code can be added to the blockchain platform code by the developers of the blockchain platform during the development process, or it can be embedded by the listening party based on its own needs, and this specification does not limit this.
[0041] One of the decentralized features that distinguishes blockchain technology from traditional technologies is that it records accounts on each node, or distributed accounting, rather than traditional centralized accounting. In order for a blockchain system to become a decentralized, honest and trustworthy system that is difficult to break, public, and cannot be tampered with, it is necessary to make distributed data records secure, clear, and irreversible in the shortest possible time. In different types of blockchain networks, in order to maintain the consistency of the ledgers in each node that records the ledger, a consensus algorithm is usually used to ensure that it is the consensus mechanism mentioned above. For example, a consensus mechanism of block granularity can be implemented between blockchain nodes. For example, after a node (such as a unique node) generates a block, if the generated block is recognized by other nodes, other nodes record the same block. For another example, a consensus mechanism of transaction granularity can be implemented between blockchain nodes. For example, after a node (such as a unique node) obtains a blockchain transaction, if the blockchain transaction is recognized by other nodes, each node that recognizes the blockchain transaction can add the blockchain transaction to the latest block maintained by itself, and ultimately ensure that each node generates the same latest block. The consensus mechanism is a mechanism for blockchain nodes to reach a consensus on block information (or block data) across the entire network, which can ensure that the latest block is accurately added to the blockchain. The current mainstream consensus mechanisms include: Proof of Work (POW), Proof of Stake (POS), Delegated Proof of Stake (DPOS), Practical Byzantine Fault Tolerance (PBFT) algorithm, HoneyBadgerBFT algorithm, etc.
[0042] Due to the decentralized nature of the blockchain network, all blockchain nodes in the blockchain network will maintain the same block data, which cannot meet the special needs of some nodes. Taking the alliance chain as an example, all alliance members can form a blockchain network, and all alliance members have corresponding blockchain nodes in the blockchain network, and can obtain all transactions and related data occurring on the blockchain network through the corresponding blockchain nodes.
[0043] However, in some cases, some alliance members may want to complete some transactions with confidentiality requirements. These alliance members hope that these transactions can be stored on the blockchain or take advantage of other advantages of blockchain technology, while preventing other alliance members from viewing these transactions and related data. Therefore, these alliance members can form an additional new blockchain network, so that the node devices corresponding to any of these alliance members can participate in the formation of multiple blockchain networks, that is, deploy multiple nodes belonging to different blockchain networks in the same node device.
[0044] In the above scenario, in order to achieve the normal operation of each blockchain network, it is necessary to configure different IP addresses, port numbers and other network resources for the multiple blockchain networks formed by the same node device. For example, in the relevant technology, an IP address is usually configured for a node device, and different port numbers are configured for each blockchain network formed by the node device, so that the combination of IP address and port is used as the network address of a blockchain network (and the blockchain node belonging to the blockchain network) formed by the node device. Accordingly, the sender can determine the network address of a blockchain network according to the above configuration, and send a blockchain message to the node device, and the blockchain device distributes the blockchain message to the corresponding blockchain node according to the network address carried by the blockchain message, so as to realize the subsequent processing of the blockchain message.
[0045] It can be seen that the above method actually allocates independent network resources for each blockchain network in which the node devices participate. However, using this configuration method, on the one hand, each blockchain network in which the node devices participate needs to be configured with different network resources, so the blockchain network needs to occupy more network resources, especially in scenarios with a large number of nodes, and may even cause network resource exhaustion, which limits the network scale to a certain extent. On the other hand, the above resource configuration process is usually completed manually by the administrator, so once a configuration error occurs, it is usually difficult to adjust, resulting in poor network stability; and in the process of adding or deleting a network, the administrator needs to manually complete more processing steps and operation processes, so the network management efficiency is low and the scalability is poor.
[0046] In order to solve the above problems, this specification proposes a network resource sharing scheme, that is, allowing multiple blockchain networks formed by node devices to share the network resources of the node devices, such as configuring the same IP address and port number for all blockchain networks. Of course, because different blockchain networks are still independent of each other, such as using their own consensus, computing, storage and other network resources, the node devices are required to distribute the received blockchain messages. Therefore, this specification proposes a blockchain message distribution method, through which the network access layer in the node device can obtain a network identifier set for recording the network identifiers of the blockchain networks to which the node instances deployed in the node device belong respectively, and then when a blockchain message is received, the blockchain message is efficiently distributed according to the set. Precisely because the multiple blockchain networks formed in the above manner can share the network resources of the node devices, there is no need to configure different network resources for each blockchain network respectively. Therefore, compared with the related technology of configuring different network resources for each blockchain network, this scheme can greatly simplify the network resource configuration process of the blockchain network and reduce the configuration difficulty, and can achieve efficient distribution of blockchain messages. The following is combined with Figure 4 The following describes the construction plan of the blockchain subnet in this manual.
[0047] See also Figure 4 , Figure 4 This is a flowchart of a method for distributing blockchain messages provided by an exemplary embodiment. Figure 4 As shown, the method is applied to a node device running a blockchain platform code, wherein the blockchain platform code forms a network access layer and node instances respectively belonging to each blockchain network in the node device, and each node instance in the node device shares the network resources corresponding to the network access layer. The method may include the following steps:
[0048] Step 402: The network access layer obtains a network identification set, and the network identification set is used to record the network identifications of the blockchain networks to which the node instances deployed in the node devices belong respectively.
[0049] First of all, it should be noted that the node device described in this specification runs the blockchain platform code, and in the process of the node device running the code, a network access layer and node instances belonging to each blockchain network are formed locally. Among them, the network access layer is used to uniformly manage network resources such as IP addresses and / or port numbers in the node device, and to uniformly distribute the blockchain messages received by the node device, and the above-mentioned node instances share the above-mentioned network resources managed by the network access layer, which helps to improve the distribution and processing efficiency of blockchain messages in multi-blockchain network scenarios.
[0050] In one embodiment, the blockchain network to which the above-mentioned multiple node instances formed in the node device belong respectively may include a blockchain main network and a blockchain subnet managed by the blockchain main network. Accordingly, the node instance belonging to the blockchain main network may be referred to as a main network node instance, and the node instance belonging to the blockchain subnet may be referred to as a subnet node instance.
[0051] Further, the main network node instance can call the subnet management contract deployed on the blockchain main network to manage the blockchain subnet by executing transactions. For example, similar to the execution of the above-mentioned networking transactions, the main network node instance can call the above-mentioned subnet management contract to trigger the node device to participate in the management of the corresponding blockchain subnet when executing the transaction to manage the blockchain subnet (hereinafter referred to as the management transaction). Among them, the above-mentioned management transaction can specify the address of the smart contract called, the calling method and the parameters passed in, etc. Further, the called contract can be the above-mentioned subnet management contract, the calling method can be the method for managing the blockchain subnet, and the parameters passed in can include attribute configuration information for the blockchain platform code, such as the code version number, whether consensus is required, the consensus algorithm type and / or the block size, etc., and this specification does not limit this. It can be understood that by calling the above-mentioned parameters passed in when managing transactions, multiple blockchain subnets formed in the node device can be centrally managed at the same time, thereby helping to improve the management efficiency of the blockchain subnet.
[0052] The above main network node instance can manage any blockchain subnet in various forms. For example, any blockchain subnet can be established to change the network configuration information of any blockchain subnet, switch the working state of any blockchain subnet, switch the working state of at least one blockchain node instance in any blockchain subnet, and / or destroy any blockchain subnet, etc., which will be explained in conjunction with the embodiments below.
[0053] In one embodiment, the main network node instance can form the above-mentioned blockchain subnet by executing transactions, that is, the above-mentioned management transaction can be a transaction for forming a blockchain subnet (hereinafter referred to as a network transaction). At this time, the transaction can include a transaction for calling a contract, and the address of the smart contract called, the calling method, and the parameters passed in can be specified in the transaction. Further, the above-mentioned contract called can be the genesis contract of the blockchain subnet or a system contract deployed in the blockchain main network, the calling method can be a method for forming a blockchain subnet, and the parameters passed in can include attribute configuration information for the blockchain platform code, such as the code version number, whether consensus is required, the consensus algorithm type and / or the block size, etc., and this specification does not limit this.
[0054] In addition, the contract called by the above networking exchange can be a subnet management contract deployed in the main network node instance, which can be a system contract or a genesis contract. Therefore, when the main network node instance executes the networking transaction, it can call the subnet management contract to trigger the node device to participate in the establishment of the corresponding blockchain subnet (that is, create a subnet node instance belonging to the blockchain subnet). Correspondingly, in response to the execution of the subnet management contract, the node device can pull up a process and execute the blockchain platform code in the process, or it can also run the code in the pulled up process (such as the process where the above main network node instance is located), thereby creating a subnet node instance in the corresponding process to complete the establishment of the blockchain subnet. By calling the attribute configuration information passed in when calling the above subnet management contract, it can be ensured that the blockchain subnet is established based on the above blockchain main network.
[0055] Of course, the transaction for forming a blockchain subnet may not be a transaction that calls a smart contract, so that a blockchain network that does not support smart contracts can also implement the technical solution of this specification, thereby quickly forming a blockchain subnet on the basis of the blockchain main network. For example, a group of network transaction type identifiers can be pre-defined. When a transaction contains the networking transaction type identifier, it indicates that the transaction is used to form a new blockchain subnet, that is, the transaction is a networking transaction. The blockchain platform code can include relevant processing logic for forming a blockchain subnet, so that when the main network node instance running the blockchain platform code executes a transaction, if it is found that the transaction contains the above-mentioned networking transaction type identifier, and the identity information of the node members participating in the formation of the blockchain subnet is included in the configuration information in the transaction, the node device can be triggered based on the above-mentioned processing logic to generate a genesis block containing the configuration information and start the blockchain node, and the blockchain node loads the genesis block to form a subnet node in the blockchain subnet.
[0056] One of the advantages of building a blockchain subnet based on the blockchain mainnet is that since the mainnet node instance has been deployed on the node device that creates the subnet node instance, the blockchain platform code used by the mainnet node instance can be reused on the subnet node instance, eliminating the need for repeated deployment of the blockchain platform code, greatly improving the efficiency of building the blockchain subnet. Moreover, since the blockchain subnet is built on the basis of the blockchain mainnet, the construction process of the blockchain subnet greatly reduces the resources consumed and the time required to build a completely independent blockchain network, and is extremely flexible.
[0057] In the above embodiment of executing transactions to form a blockchain subnet, the networking transaction can be initiated by the administrator of the blockchain main network, that is, only the administrator is allowed to form a blockchain subnet based on the blockchain main network, and avoid opening the distribution rights of blockchain messages to ordinary users to prevent security issues caused by this. In some cases, ordinary users of the blockchain main network can also be allowed to initiate the above networking transactions to meet the networking needs of ordinary users, so that ordinary users can still quickly form a blockchain subnet when it is inconvenient for administrators to initiate transactions.
[0058] by Figure 5 As shown in the example, the blockchain network includes subnet0, subnet1 and subnet2, where the blockchain main network is subnet0, and the blockchain nodes contained in subnet0 are nodeA, nodeB, nodeC, nodeD and nodeE, etc.; the blockchain subnet formed on the basis of subnet0 is subnet1; and subnet2 is relatively independent of subnet0 and subnet1. Therefore, the blockchain nodes nodeA, nodeA1 and nodeA2 in the same node device belong to different blockchain networks respectively, that is, the node device participates in the above three blockchain networks at the same time.
[0059] The blockchain nodes included in the above blockchain main network subnet0 are nodeA, nodeB, nodeC, nodeD and nodeE. Assume that the node members corresponding to nodeA, nodeB, nodeC and nodeD want to form a blockchain subnet: if nodeA is an administrator and only administrators are allowed to initiate networking transactions, then nodeA can initiate the above networking transaction to subnet0; if nodeE is an administrator and only administrators are allowed to initiate networking transactions, then nodeA~nodeD need to make a request to nodeE so that nodeE can initiate the above networking transaction to subnet0; if nodeE is an administrator but ordinary users are allowed to initiate networking transactions, then nodeA~nodeD can initiate the above networking transaction to subnet0. Of course, whether it is an administrator or an ordinary user, the node members corresponding to the blockchain node that initiates the networking transaction do not necessarily participate in the formed blockchain subnet. For example, if nodeA is an administrator but ordinary users are allowed to initiate networking transactions, then although the blockchain subnet is finally formed by the node members corresponding to nodeA, nodeB, nodeC and nodeD, nodeE can initiate the above networking transaction to subnet0.
[0060] When a blockchain subnet is established on the basis of the blockchain mainnet, it is easy to understand that there will be a logical hierarchical relationship between the blockchain subnet and the blockchain mainnet. Figure 5When the blockchain subnet subnet1 is built on the subnet0 shown in the figure, it can be considered that subnet0 is in the first layer and subnet1 is in the second layer. Then, the blockchain main network in this specification can be the underlying blockchain network, and the underlying blockchain network is not a blockchain subnet built on the basis of other blockchain networks, such as Figure 5 The subnet0 in the figure can be considered as the main blockchain network of the underlying blockchain network type. Of course, the main blockchain network can also be a subnet of other blockchain networks, such as Figure 5 On the basis of subnet1 in the above example, another blockchain subnet is further established. At this time, subnet1 can be considered as the blockchain main network corresponding to the blockchain subnet, and this does not affect the fact that subnet1 also belongs to the blockchain subnet created on subnet0. For example, subnet node nodeA11 can also be generated based on subnet node nodeA1, and the blockchain subnet subnet11 to which the node belongs is equivalent to the blockchain subnet established on the basis of blockchain subnet subnet1. At this time, the blockchain main network subnet0 is located in the first layer, the blockchain subnet subnet1 is located in the second layer, and the blockchain subnet subnet11 is located in the third layer, that is, a three-layer blockchain network is established in the node device. Of course, a four-layer or even more-layer blockchain network can be established in the node device through a similar process, which will not be repeated here. It can be seen that the blockchain main network and the blockchain subnet are actually relative concepts. The same blockchain network can be a blockchain main network in some cases and a blockchain subnet in other cases.
[0061] The main network node and subnet node mentioned above can correspond to the same node member, for example, they correspond to the same consortium chain member in the consortium chain scenario. Because the main network node belongs to the blockchain main network and the subnet node belongs to the blockchain subnet, the blockchain member can participate in the transactions of the blockchain main network and the blockchain subnet respectively. For example, the node member corresponding to the blockchain main network nodeA and the blockchain subnet nodeA1 can participate in the transactions of subnet0 and subnet1 respectively. In addition, since the blockchain main network and the blockchain subnet belong to two independent blockchain networks, the blocks generated by the main network node and the blocks generated by the subnet node are respectively stored in different storages on the node device, such as the storage can be a database, thereby realizing the mutual isolation between the storages used by the main network node and the subnet node respectively, so that the data generated by the blockchain subnet will only be synchronized between the node members of the blockchain subnet, and the blockchain members who only participate in the blockchain main network cannot obtain the data generated on the blockchain subnet, realizing the data isolation between the blockchain main network and the blockchain subnet, and meeting the transaction needs of some node members (i.e., the node members participating in the blockchain subnet).
[0062] It can be seen that the main network node and the sub-network node are logically divided blockchain nodes. From the perspective of physical devices, it is equivalent to the node devices that deploy the main network node and the sub-network node as mentioned above participating in both the blockchain main network and the blockchain sub-network. Since the blockchain main network and the blockchain sub-network are independent of each other, the identity systems of the two blockchain networks are also independent of each other. Therefore, even if the main network node and the sub-network node can use the same public key, they should still be regarded as different blockchain nodes. For example, in Figure 5 In the example, nodeA in subnet0 is equivalent to the main network node, and the node device that deploys nodeA generates nodeA1 belonging to subnet1, which is equivalent to the subnet node. It can be seen that since the identity systems are independent of each other, even if the public key used by the subnet node is different from that of the main network node, it will not affect the implementation of the solution in this manual.
[0063] Of course, the node members of the blockchain subnet are not necessarily only some of the node members of the blockchain main network. In some cases, the node members of the blockchain subnet can be completely consistent with the node members of the blockchain main network. At this time, all blockchain members can obtain data on the blockchain main network and the blockchain subnet, but the data generated by the blockchain main network and the blockchain subnet can still be isolated from each other. For example, one type of business can be implemented on the blockchain main network and another type of business can be implemented on the blockchain subnet, so that the business data generated by these two types of business can be isolated from each other.
[0064] like Figure 6 As shown, the node device forms a network access layer by running the blockchain platform code, and blockchain nodes including network node nodeA (main network node), network node nodeA1 (sub-network node) and network node nodeA2. In the figure, the main network node nodeA should be regarded as the aforementioned main network node instance, and the sub-network node nodeA1 should be regarded as the aforementioned sub-network node instance, for special explanation.
[0065] Each of the above-mentioned blockchain nodes may include a consensus module, a computing module, and a storage module, so that the blockchain node can realize basic functions such as transaction consensus, data computing, and data storage. Of course, any blockchain node may also include other functional modules so that the node members corresponding to the node can realize the corresponding functions through the functional modules in the node. The embodiments of this specification do not limit the specific functional modules included in any blockchain node. Taking the consensus module as an example, some blockchain nodes in any blockchain network may not participate in the transaction consensus, so these blockchain nodes may not include the consensus module, while some blockchain nodes in the blockchain network that participate in the transaction consensus include this module.
[0066] As mentioned above, the blockchain platform code for creating different blockchain nodes can be reused, so the same modules contained in the above-mentioned different blockchain nodes can correspond to the same section of blockchain platform code. Taking the calculation module as an example, assuming that both nodeA and nodeA1 need to implement the same calculation function, the two can reuse the same section of blockchain platform code (hereinafter referred to as calculation code) for implementing the calculation function. Among them, nodeA and nodeA1 can use the calculation code to form a calculation module for their own calculation process, that is, nodeA and nodeA1 respectively contain their own calculation modules, and the calculation modules of the two are generated by the above-mentioned calculation code. Alternatively, a calculation module can also be generated according to the above-mentioned calculation code for nodeA and nodeA1 to use together, such as the two can independently call the module for calculation in time-sharing, so that the calculation module is shared by each node, avoiding the repeated generation of the calculation module, and further improving the node deployment and code execution efficiency.
[0067] The above-mentioned network access layer includes an access module and a network management module, wherein the access module is used to configure network parameters such as the IP address and port number of the node device, and centrally receive blockchain messages sent to the node device by other nodes; the network management module is used to manage the blockchain network in the node device, and determine the target blockchain network corresponding to the received blockchain message based on the acquired network identification set, so as to realize the distribution of blockchain messages.
[0068] For any completed blockchain network, the main network node instance can further manage it. In one embodiment, the main network node instance can modify the network configuration information of any blockchain subnet. For example, the administrator of the blockchain main network or the subnet member with management authority over the blockchain subnet can modify at least one subnet configuration information such as the data format of the transaction executed by the blockchain subnet, the transaction verification algorithm adopted, whether to reach a consensus on the transaction, the consensus algorithm adopted in the consensus process, the smart contract deployment authority, the smart contract call authority, and the smart contract upgrade authority, thereby realizing the management of the configuration information of the blockchain subnet.
[0069] Of course, the main network node instance can also switch the working state of any blockchain subnet. For example, in the alliance chain scenario, some (or all) alliance chain members can form a blockchain subnet subnet1 based on the blockchain main network subnet0. The working state of the newly formed subnet1 can be set to the open state by default, so that the alliance chain members corresponding to subnet1 can participate in related transactions as soon as possible. Of course, in order to ensure the management of the subnet usage rights, some members of subnet1 (such as administrators, etc.) can also set the working state of the subnet to the open state, which will not be repeated. Further, in the process of relevant members participating in the above-mentioned transactions, if there is an emergency such as a processing failure, subnet1 can suspend the current transaction, so that its working state is updated to the suspended state. Moreover, because the transactions that the alliance chain members need to process often have certain time limit requirements, such as the need to be executed within a pre-specified time period, etc., after completing the execution of the above-mentioned transactions within the preset time period, the working state of subnet1 can be set to the terminated state, so that the subnet1 can be used directly to execute other transactions in the future, so that there is no need to re-establish a new blockchain subnet when executing other transactions in the future, thereby improving the execution efficiency of transactions. Furthermore, the main network node instance can also switch the working state of at least one blockchain node instance in any blockchain subnet, such as nodeA in subnet0 switches the working state of nodeA1 in subnet1 between the above-mentioned open state, pause state and terminated state. In addition, if the above-mentioned transaction is a one-time transaction or the various participants of subnet1 no longer need to execute the transaction together, nodeA can also destroy subnet1 to reduce the number of subnets that the blockchain main network needs to manage and improve the efficiency of subnet management.
[0070] It can be seen that the main network node instance can manage any blockchain subnet or at least one blockchain node instance in any blockchain main network through the above-mentioned subnet management contract deployed in the blockchain main network, thereby realizing efficient management of blockchain subnets or blockchain nodes by calling smart contracts.
[0071] It can be seen from the above embodiments that when a node device executes a management transaction, the working state of the blockchain subnet in the node device may change. Of course, the main network node instance in the node device may also cause the working state of the blockchain subnet to change when executing other transactions or other factors, that is, there may be many possibilities for the change of the working state of the blockchain subnet, and this specification does not limit this.
[0072] The network identifier described in the embodiments of this specification is a globally unique identifier of the blockchain network, which is used to specifically represent each blockchain network to facilitate the distinction of blockchain networks. Among them, the above network identifier set can be maintained by the blockchain network, or by the main network node instance, node device management organization or other third parties related to the blockchain network, and the embodiments of this specification are not limited to this.
[0073] In one embodiment, the above-mentioned network identification set can be used to record the network identification of the blockchain network in an available state. Because the newly formed blockchain network is usually set to the open state, in the case of blockchain network maintenance, the network access layer can add the network identification of any blockchain network to the network identification set it maintains after participating in and successfully forming the network; or, after detecting that the network status of the blockchain network has changed (through the aforementioned event subscription mechanism), the network identification in the maintained network status set can be updated accordingly according to the detected status change; or, in the case that any blockchain network is destroyed, the network identification of the blockchain network can be removed from the network identification set accordingly. Figure 5 For example, the network access layer can add the network ID of the blockchain subnet subnet0 to the network ID set after the subnet0 is established, or remove the network ID of the subnet1 from the network ID set when the working state of the subnet1 is switched from the startup state to the pause state, or remove the network ID of the subnet2 from the network ID set when the subnet2 is destroyed.
[0074] In another embodiment, the network identification set may also record the operating status of each blockchain network, so that the blockchain message can be distributed to the corresponding target node instance when the target blockchain network is in an available state. Among them, the state information can be recorded in accordance with the blockchain identification. For example, when recorded in a list form, the network identification of a blockchain network and the current working state of the blockchain network can be recorded in any table item. It can be understood that the network access layer can update the operating state of each blockchain network recorded in the network identification set according to the state change of each blockchain network (reflecting the actual operating state of the blockchain network). Therefore, after receiving the blockchain message through the access module, the network access layer can extract the network identification of the target blockchain network carried by it from the message, and can determine whether the network is currently in an available state (such as in an open state) according to the identification according to the working state corresponding to the target blockchain network recorded in the network identification set, and when it is determined that the target blockchain network is in an available state, the blockchain message is distributed to the blockchain node (and the target blockchain node described below) belonging to the target blockchain network deployed on the node device.
[0075] Among them, the network access layer can actively monitor the changes in the working status of each blockchain network in the node device, and when the working status of at least one blockchain network is monitored to change, the working status of the blockchain network is updated in the above-mentioned network identification set. Taking the blockchain subnet as an example, when the main network node instance executes the management transaction, it can call the above-mentioned subnet management contract to manage the blockchain subnet, and generate a corresponding receipt after the transaction is executed to record the information related to the execution of the smart contract. In this way, relevant information about the contract execution result can be obtained by querying the receipt of the transaction. Among them, the above-mentioned contract execution result can be expressed as an event in the receipt, so the network access layer can monitor the status changes of the blockchain subnet through the event mechanism.
[0076] For example, the network access layer can monitor the event content of the event generated after the transaction that calls the subnet management contract is executed to learn about the status change of the blockchain subnet. Take the transaction in which nodes nodeA~nodeE on Subnet0 execute the addsubnet() method in the Subnet contract as an example. After the transaction passes the consensus, nodeA~nodeE respectively execute the addsubnet() method and pass in the configuration information to obtain the corresponding execution results.
[0077] The execution result of the contract may include the configuration information, and the execution result may be in the receipt mentioned above, which may include an event related to the execution of the addsubnet() method, that is, a networking event. The topic of the networking event may include a predefined networking event identifier to distinguish it from other events. For example, in the event related to the execution of the addsubnet() method, the content of the topic is the keyword subnet, and the keyword is different from the topic in the event generated by other methods. Then, nodeA~nodeE can determine that they have listened to the event related to the execution of the addsubnet() method, that is, the networking event, by monitoring the topics contained in each event in the generated receipt when they have listened to the topic containing the keyword subnet.
[0078] Alternatively, the network access layer can also pre-subscribe to events based on logs, so that after the events generated by the execution of the above-mentioned subnet management contract are written into the logs, the event notification center running in the node device will promptly notify the network access layer, so that the network access layer can monitor the state changes of the blockchain subnet, and update the working state of the blockchain subnet in the above-mentioned network identification set according to the state changes. Through the above-mentioned event monitoring or event subscription method, the network access layer can timely and accurately monitor the state changes of the blockchain subnet, thereby realizing the timely update of the working state of the blockchain subnet. Of course, the main network node instance can also inform the network access layer through other methods other than the event mechanism. For example, when a state detection module is locally deployed on the main network node instance, it can periodically detect the subnet state through the module, and send a reminder message to the network access layer when a state change is detected, etc., which will not be repeated.
[0079] In one embodiment, the network identifier of the blockchain network corresponding to each node instance in the above-mentioned node device can be allocated by the network access layer. It is understandable that the above-mentioned allocation can be allocated by the network access layer in the preset node device (such as the node device corresponding to the administrator) or the first node device that executes the contract (such as the node device with the fastest contract execution) in each node device participating in the establishment of the blockchain network, and after the allocation is completed, the corresponding node in the node device is synchronized to other nodes (consensus can also be reached if necessary).
[0080] Taking the formation process of a subnet node instance as an example, when the main network node instance executes the above networking transaction to form a blockchain subnet, it can first send a notification message to the network management module so that the network management module can allocate a network identifier (i.e., a subnet identifier) to the blockchain subnet to be formed. Furthermore, the network management module can record the subnet identifier in the above network identifier set on the one hand, and send the subnet identifier to the main network node instance and the transaction initiator on the other hand: the main network node instance writes the subnet identifier into the genesis block of the newly formed blockchain subnet to generate the blockchain subnet corresponding to the subnet node instance; the transaction initiator records the subnet identifier in the blockchain message generated by it that needs to be processed by the blockchain subnet, so that the network access layer can accurately distribute the blockchain message to the subnet node instance of the newly formed blockchain subnet according to the above subnet identifier maintained locally.
[0081] Of course, the network access layer can also pre-allocate a subnet identifier when determining that any blockchain transaction it receives is a networking transaction, and associate the subnet identifier with the networking transaction and send it to the main network node instance of the blockchain main network. Thus, the main network node instance can use the received subnet identifier to establish a blockchain subnet (i.e., establish a blockchain subnet corresponding to the subnet identifier) when executing the networking transaction, and the network access layer can record the pre-allocated subnet identifier in the network identifier set when determining that the blockchain subnet is successfully established, and send the subnet identifier to the transaction initiator: the transaction initiator can record the subnet identifier in the blockchain message generated by it that needs to be processed by the blockchain subnet, and the network access layer can accurately distribute the received blockchain message to the subnet node instance of the newly established blockchain subnet according to the locally maintained subnet identifier.
[0082] In the above embodiment, the subnet identifier can also be reached through consensus by each main network node that forms the blockchain subnet, and the corresponding blockchain subnet is created after the consensus is reached. Moreover, the network access layer in the node device where each main network node is located can send the subnet identifier to the corresponding node member, so that the node members corresponding to each subnet node that participates in forming the blockchain subnet can all know the subnet identifier of the blockchain subnet, so as to subsequently distribute the blockchain message that needs to be processed by the blockchain subnet.
[0083] In one embodiment, in the case of obtaining the above-mentioned network identification set from other devices, in order to reduce the frequency of obtaining the network identification set, the network access layer can also temporarily obtain the above-mentioned network identification set when receiving a blockchain message. Of course, in the application of the solution, the aforementioned method of detecting the subnet status to obtain in advance can be adopted according to the actual situation, or the method of temporarily obtaining after receiving the blockchain message can be adopted to balance the timeliness of the subnet status information and the processing efficiency of the blockchain message. This specification does not limit this.
[0084] Step 404: When the network access layer receives the blockchain message, it determines the target blockchain network corresponding to the blockchain message based on the network identifier set, and distributes the blockchain message to the target node instance belonging to the target blockchain network deployed on the node device.
[0085] It should be noted that the blockchain messages to be distributed in the embodiments of this specification may have various possibilities, for example, they may be blockchain messages sent from user devices or other node devices to the above-mentioned node devices, they may also be consensus messages generated between blockchain nodes during the consensus process, they may also be heartbeat messages sent between node devices in the blockchain network for keeping alive, etc., they may also be block data when synchronizing blocks between node devices in the blockchain network, and the embodiments of this specification do not further limit this.
[0086] As mentioned above, the blockchain messages received by the node devices are uniformly distributed by the network access layer in the node devices. When the network access layer receives blockchain messages sent by other nodes or devices for a certain blockchain network, it can determine whether the blockchain network (i.e., the target blockchain network corresponding to the blockchain message) is in an available state based on the network identifier set obtained in advance (before receiving the blockchain message) or temporarily (after receiving the blockchain message), and distribute the blockchain message to the target blockchain network if it is in an available state, so that the target blockchain network can process the message.
[0087] Among them, the blockchain message can carry the network identifier of a certain blockchain network. Taking blockchain transactions as an example, in the alliance chain scenario, for any alliance chain member among multiple alliance chain members (equivalent to multiple node members) that jointly handle a certain transaction, it can determine the blockchain network (i.e., the target blockchain network) in which each alliance chain member participates according to the actual identity of the above-mentioned alliance chain members, so as to process the blockchain transaction corresponding to the transaction. Furthermore, any of the above-mentioned alliance chain members can determine the network identifier of the target blockchain network (hereinafter referred to as the target network identifier), and include the target network identifier in the blockchain transaction related to the above-mentioned transaction generated by the corresponding device, so that after receiving the blockchain transaction, the network access layer in the node device can distribute the target blockchain transaction to the target node instance belonging to the target blockchain network in the node device according to the target network identifier contained therein. Among them, the device corresponding to any of the above-mentioned alliance chain members can maintain the network identifiers of each blockchain network in which the member participates, so as to determine the above-mentioned target network identifier accordingly, and then accurately generate blockchain transactions.
[0088] Among them, any of the above-mentioned alliance chain members can generate the above-mentioned target blockchain transaction through the client of DApp (Decentralized Application). At this time, the client can locally maintain the network identification of all blockchain networks in which the node devices corresponding to the alliance chain member participate. Alternatively, the alliance chain member can also send business-related information to the BaaS (Blockchain as a Service) platform through the client of the application program, so that the platform can generate the target blockchain transaction based on the business-related information. Of course, the BaaS platform can maintain the network identification of all blockchain networks in which the node devices corresponding to the alliance chain member participate.
[0089] Furthermore, after receiving the target blockchain transaction, the target node instance can synchronize the transaction to other node instances belonging to the target blockchain network, so that the node devices corresponding to each of the above-mentioned alliance chain members can execute the transaction after reaching consensus on the transaction, thereby completing the above-mentioned transaction.
[0090] In one embodiment, the network access layer can determine the blockchain network indicated by the target network identifier as the above-mentioned target blockchain network when there is a target network identifier carried by the blockchain message in the network identifier set. Of course, before determining the target blockchain network, the network access layer does not know which network identifier in the network identifier set is the target network identifier (that is, it does not know which blockchain network is the target blockchain network), but only when it is found that a certain network identifier in the network identifier set is exactly the target network identifier carried in the blockchain message (that is, the identifier is the target network identifier), it determines that the blockchain network indicated by the network identifier is the target blockchain network. In addition, after obtaining the above-mentioned network identifier set, the network access layer can save the set in its own corresponding database or memory or other storage space, and then after extracting the target blockchain identifier from the blockchain message, it can read the network identifier set from the above-mentioned storage space and perform the above-mentioned query.
[0091] like Figure 6As shown, when it is determined that the blockchain message contains the network identifier of the blockchain network subnet1, if the above-mentioned blockchain identifier set is only used to record the network identifier of the blockchain network in an available state, and the network identifier set records the network identifier of the blockchain network subnet1, then the network access layer can determine that the blockchain network subnet1 is the target blockchain network and is in an available state. Alternatively, if the above-mentioned blockchain identifier set is used to record the network identifier and working status of each blockchain network, the network access layer can query the working status of subnet1 in the network identifier set through the network identifier of the blockchain network subnet1, and when the query result shows that subnet1 is in an available state, determine that subnet1 is the target blockchain network and is in an available state. Furthermore, the network access layer can distribute the above-mentioned blockchain message to the target node instance belonging to subnet1 deployed on the node device (i.e., node instance nodeA1).
[0092] In addition, if Figure 6 As shown, in addition to the access module, the above network access layer may also include distribution modules corresponding to each blockchain network, such as distribution module 0 corresponding to blockchain network subnet0, distribution module 1 corresponding to blockchain network subnet1, and distribution module 2 corresponding to blockchain network subnet2. Among them, the distribution module corresponding to any blockchain network can be understood as the node interface of the node instance belonging to the blockchain network in the network access layer (such as distribution module 0 can be considered as the node interface of node instance nodeA in the network access layer, etc.), and the network access layer can realize the management and data transmission of each blockchain network through each interface module. Therefore, when distributing blockchain messages, the network access layer can distribute blockchain messages to the target node instance through the target distribution module corresponding to the target blockchain network.
[0093] As mentioned above, the network access layer and the node instance can run in the same or different processes. In one embodiment, the blockchain platform code can be run in the process where the network access layer is located, so that the node instance belonging to the blockchain network is deployed in the process. Since there is no cross-process interaction involved, this method can reduce the difficulty of deploying the blockchain network, thereby improving the deployment efficiency.
[0094] In another embodiment, the process where the network access layer is located can be different from the process where the node instance is located. For example, the network access layer is in the first process, and the node instances of each blockchain network are in the second process; for another example, the network access layer is in the first process, and the node instances of each blockchain network are in a process respectively, such as the main network node instance corresponding to the blockchain network (main network) subnet0 is in the second process, the subnet node instance corresponding to the blockchain network (subnet) subnet1 is in the third process, and the subnet node instance corresponding to the blockchain network subnet2 is in the fourth process, etc. At this time, the process where the network access layer is located can be set as the default processing process for the blockchain message received by the node device to ensure that the blockchain message received by the node device can be uniformly distributed by the network access layer.
[0095] Furthermore, when the above-mentioned network access layer and the target blockchain network are in different processes, the network access layer can realize the distribution of blockchain messages through cross-process interaction: the network access layer can first determine the target node process where the target node instance is located, and determine the communication interface for calling the target node process, and then distribute the blockchain message to the target node instance through the interface, thereby realizing cross-process interaction.
[0096] For example, in the case where the above-mentioned blockchain message is a blockchain transaction, after the network access layer distributes the blockchain transaction to the target node instance belonging to the target blockchain network, the target node instance can synchronize the received blockchain transaction to other subnet node instances belonging to the target blockchain network. Furthermore, each subnet node instance in the target blockchain network can use the aforementioned consensus mechanism to reach a consensus on the blockchain transaction, and when the consensus is passed, each subnet node executes the blockchain transaction and saves the corresponding execution results in the corresponding database. Among them, the specific process of the above-mentioned consensus, execution and storage can be referred to the records in the aforementioned embodiments and related technologies, and will not be repeated here.
[0097] In fact, because the current working status of each blockchain network is not fixed (the working status may switch), when querying the target network identifier in the above network status set, there may be a situation where the network identifier set indicates that the target blockchain network is unavailable. For example, the target network identifier may not be found. At this time, the distribution of blockchain messages cannot be completed; or the working status of the target blockchain network recorded in the network identifier set may be unavailable, such as the target blockchain network is in a suspended state or a terminated state, or even has been destroyed. At this time, even if the blockchain message is distributed, the target blockchain network cannot effectively process the message. Therefore, at this time, the network access layer can terminate the distribution of the above blockchain message to avoid invalid distribution of blockchain messages. Of course, a retry mechanism can also be pre-set, that is, when the above subnet status information may indicate that the target blockchain network is in an unavailable state, the target blockchain network can be re-determined after waiting for a certain period of time to ensure that the subnet status information is updated within the above period of time, and the effective distribution and subsequent processing of blockchain messages can be achieved.
[0098] In addition, the blockchain messages received by the network access layer in the node device may not all be the target blockchain networks designated by the message initiator to process the messages, so the blockchain messages may not carry the network identification of any blockchain network. Therefore, in the case of receiving a message that does not carry the network identification of any blockchain network, the network access layer can distribute the blockchain message to the node instance belonging to the default blockchain network deployed on the node device, wherein the default blockchain network can include any one or more of the aforementioned blockchain networks, such as the aforementioned blockchain main network or any blockchain subnet. Thus, the blockchain messages that do not receive any network identification are effectively processed by the preset default blockchain network, which guarantees the compatibility between this solution and the solutions in the related technology to a certain extent.
[0099] like Figure 6As shown, after receiving the blockchain message, the access module in the network access layer can determine the target blockchain network corresponding to the blockchain message through the network management module. For example, the network management module can first determine whether the message carries the network identifier of the blockchain network: if there is no blockchain identifier, the network management module can determine the current default blockchain network. For example, when the default blockchain network is the blockchain main network subnet0, the message can be sent to the main network node instance nodeA corresponding to subnet0 through the distribution module 0 corresponding to subnet0. On the contrary, if the blockchain message carries the network identifier of the blockchain network, the network access layer can distribute the blockchain message according to the network identifier. For example, when the above network identifier is the network identifier of the blockchain subnet subnet1, the message can be sent to the subnet node instance nodeA1 corresponding to subnet1 through the distribution module 1 corresponding to subnet1; or when the above network identifier is the network identifier of the blockchain network subnet2, the message can be sent to the node instance nodeA2 corresponding to subnet2 through the distribution module 2 corresponding to subnet2, which will not be repeated.
[0100] Through the above method, the blockchain node that receives the blockchain message can process the blockchain message accordingly. For example, when the blockchain message is a blockchain transaction, the blockchain transaction can be consensused and / or executed; when the blockchain message is a consensus message, the consensus process for a certain transaction can be completed according to the consensus message; when the blockchain message is a heartbeat message, the network node can be kept alive according to the heartbeat message; when the blockchain message is block data, the block data can be verified and / or stored, etc., which will not be repeated. Thus, through the above process, the processing process for blockchain transactions is completed.
[0101] Figure 7 This is a schematic diagram of a device structure provided by an exemplary embodiment. Figure 7 At the hardware level, the device includes a processor 702, an internal bus 704, a network interface 706, a memory 708, and a non-volatile memory 710, and may also include hardware required for other services. One or more embodiments of this specification may be implemented based on software, such as the processor 702 reading the corresponding computer program from the non-volatile memory 710 into the memory 708 and then running it. Of course, in addition to the software implementation, one or more embodiments of this specification do not exclude other implementations, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0102] Figure 8This is a block diagram of a blockchain message distribution device provided by an exemplary embodiment. Please refer to Figure 8 , the device can be applied to Figure 7 The device shown in the figure is used to implement the technical solution of this specification. The blockchain message distribution device is applied to a node device running a blockchain platform code, wherein the blockchain platform code forms a network access layer and node instances belonging to each blockchain network in the node device, and each node instance in the node device shares the network resources corresponding to the network access layer. The device may include:
[0103] A set acquisition unit 801 enables the network access layer to acquire a network identification set, where the network identification set is used to record the network identifications of the blockchain networks to which the node instances deployed in the node devices belong respectively;
[0104] The message distribution unit 802 enables the network access layer to determine the target blockchain network corresponding to the blockchain message according to the network identification set when receiving the blockchain message, and distribute the blockchain message to the target node instance belonging to the target blockchain network deployed on the node device.
[0105] Optionally, the network identifier set is used to record the network identifiers of blockchain networks in an available state; or,
[0106] The network identification set records the operating status of each blockchain network, and the blockchain message is distributed to the target node instance when the target blockchain network is in an available state.
[0107] Optionally, the network identifier of each blockchain network is allocated by the network access layer.
[0108] Optionally, the network access layer includes a distribution module corresponding to each blockchain network; the network access layer distributes the blockchain message to the target node instance, including:
[0109] The network access layer distributes the blockchain message to the target node instance through a target distribution module corresponding to the target blockchain network.
[0110] Optionally, the message distribution unit 802 is further configured to:
[0111] When the target network identifier carried by the blockchain message exists in the network identifier set, the network access layer determines the blockchain network indicated by the target network identifier as the target blockchain network.
[0112] Optionally, also include:
[0113] The distribution termination unit 803 causes the network access layer to terminate distribution of the blockchain message when the network identifier set indicates that the target blockchain network is unavailable.
[0114] Optionally, also include:
[0115] The default distribution unit 804 enables the network access layer to distribute the blockchain message to the blockchain node instance belonging to the default blockchain network deployed on the node device when the blockchain message does not carry the network identifier of any blockchain network, and the default blockchain network includes at least one of the blockchain networks.
[0116] Optionally, the blockchain network includes a blockchain main network and a blockchain subnet managed by the blockchain main network.
[0117] Optionally, also include:
[0118] The subnet management unit 805 enables the main network node instance belonging to the blockchain main network to call the subnet management contract deployed on the blockchain main network to trigger the node device to participate in the management of the corresponding blockchain subnet when executing the transaction of managing the blockchain subnet.
[0119] Optionally, the main network node instance manages any blockchain subnet, including at least one of the following:
[0120] Establish any of the above blockchain subnets;
[0121] Destroy any of the aforementioned blockchain subnets;
[0122] Change the network configuration information of any blockchain subnet;
[0123] Switching the working status of any of the blockchain subnets;
[0124] Switch the working state of at least one blockchain node instance in any of the blockchain subnets.
[0125] Optionally, the blockchain main network is an underlying blockchain network; or, the blockchain main network is a subnet of other blockchain networks.
[0126] Optionally, the network access layer and the node instance are in the same process.
[0127] Optionally, the network access layer and the node instance are in different processes, and the process in which the network access layer is located is set as the default processing process for blockchain messages received by the node device.
[0128] Optionally, the message distributing unit 802 is further configured to:
[0129] The network access layer determines the target node process where the target node instance is located, and distributes the blockchain message to the target node instance by calling the communication interface of the target node process.
[0130] Optionally, the network resources corresponding to the network access layer include:
[0131] IP address and / or port number.
[0132] Optionally, the blockchain message includes one of the following:
[0133] Blockchain transactions, consensus messages, heartbeat messages, and block data.
[0134] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0135] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0136] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take 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.) containing computer-usable program code.
[0137] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks 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 produce 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.
[0138] This specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media including storage devices.
[0139] 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.
[0140] 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 In a typical configuration, a computer includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0141] The memory may include non-permanent storage 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.
[0142] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. 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 disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, disk storage, quantum memory, graphene-based storage media 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.
[0143] 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.
[0144] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0145] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0146] It should be understood that although the terms first, second, third, etc. may be used to describe various information in one or more embodiments of this specification, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0147] The above description is merely a preferred embodiment of one or more embodiments of the present specification and is not intended to limit one or more embodiments of the present specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present specification shall be included in the scope of protection of one or more embodiments of the present specification.
Claims
1. A method for distributing blockchain messages, applied to a node device running a blockchain platform code, wherein the blockchain platform code forms a network access layer and a plurality of node instances respectively belonging to different blockchain networks in the node device, and each node instance in the node device shares the network resources corresponding to the network access layer, wherein the network resources corresponding to the network access layer include an IP address and / or a port number, and the method comprises: The network access layer obtains a network identification set, where the network identification set is used to record the network identifications of the blockchain networks to which the node instances deployed in the node devices belong respectively; When the network access layer receives a blockchain message carrying a target network identifier, it determines the target blockchain network corresponding to the blockchain message based on the network identifier set, and distributes the blockchain message to the target node instance belonging to the target blockchain network deployed on the node device.
2. The method according to claim 1, The network identification set is used to record the network identification of the blockchain network in an available state; or, The network identification set records the operating status of each blockchain network, and the blockchain message is distributed to the target node instance when the target blockchain network is in an available state.
3. According to the method of claim 1, the network identifier of each blockchain network is allocated by the network access layer.
4. According to the method of claim 1, the network access layer includes a distribution module corresponding to each blockchain network; the network access layer distributes the blockchain message to the target node instance, including: The network access layer distributes the blockchain message to the target node instance through a target distribution module corresponding to the target blockchain network.
5. According to the method of claim 1, determining the target blockchain network corresponding to the blockchain message according to the network identifier set comprises: When the target network identifier exists in the network identifier set, the network access layer determines the blockchain network indicated by the target network identifier as the target blockchain network.
6. The method according to claim 5, further comprising: When the network identification set indicates that the target blockchain network is unavailable, the network access layer terminates distribution of the blockchain message.
7. The method according to claim 1, further comprising: In the case where the blockchain message does not carry the network identification of any blockchain network, the network access layer distributes the blockchain message to the blockchain node instance belonging to the default blockchain network deployed on the node device, and the default blockchain network includes at least one of the blockchain networks.
8. According to the method of claim 1, the blockchain network includes a blockchain main network and at least one blockchain subnet managed by the blockchain main network.
9. According to the method of claim 8, the blockchain subnet is established based on the blockchain mainnet.
10. According to the method of claim 9, the main network node instance belonging to the blockchain main network forms any blockchain subnet, including: The main network node instance belonging to the blockchain main network responds to the networking transaction and calls the system contract or the genesis contract to create a subnet node instance belonging to any blockchain subnet in the node device.
11. According to the method of claim 9, the blockchain platform code includes processing logic for creating a subnet node instance, and the main network node instance belonging to the blockchain main network forms any blockchain subnet, including: In response to a pending transaction containing a preset networking transaction type identifier, the main network node instance belonging to the blockchain main network triggers the node device to generate and start a genesis block containing the identity information based on the processing logic when determining that the pending transaction carries the identity information of the node member; The main network node instance belonging to the blockchain main network loads the genesis block to form a subnet node instance belonging to any blockchain subnet.
12. The method according to claim 8, further comprising: When executing a transaction for managing a blockchain subnet, the main network node instance belonging to the blockchain main network calls the subnet management contract deployed on the blockchain main network to trigger the node device to participate in the management of the corresponding blockchain subnet. The transaction for managing the blockchain subnet is used to indicate the address of the subnet management contract being called, the calling method and the passed-in parameters.
13. According to the method of claim 12, the transaction is initiated by an administrator or an ordinary user of the blockchain main network.
14. According to the method of claim 12, the main network node instance manages any blockchain subnet, including at least one of the following: Establish any of the above blockchain subnets; Destroy any of the aforementioned blockchain subnets; Change the network configuration information of any blockchain subnet; Switching the working status of any of the blockchain subnets; Switch the working state of at least one blockchain node instance in any of the blockchain subnets.
15. According to the method of claim 8, the blockchain main network is the underlying blockchain network; or, the blockchain main network is a subnet of other blockchain networks.
16. The method according to claim 1, wherein the network access layer and the node instance are in the same process.
17. According to the method of claim 1, the network access layer and the node instance are in different processes, and the process in which the network access layer is located is set as the default processing process for the blockchain message received by the node device.
18. The method according to claim 17, wherein the network access layer distributes the blockchain message to the target node instance, comprising: The network access layer determines the target node process where the target node instance is located, and distributes the blockchain message to the target node instance by calling the communication interface of the target node process.
19. The method according to claim 1, wherein the blockchain message comprises one of the following: Blockchain transactions, consensus messages, heartbeat messages, and block data.
20. A blockchain message distribution device, applied to a node device running a blockchain platform code, wherein the blockchain platform code forms a network access layer and a plurality of node instances respectively belonging to different blockchain networks in the node device, and each node instance in the node device shares the network resources corresponding to the network access layer, wherein the network resources corresponding to the network access layer include an IP address and / or a port number, and the device comprises: A set acquisition unit enables the network access layer to acquire a network identification set, where the network identification set is used to record the network identifications of the blockchain networks to which the node instances deployed in the node devices respectively belong; The message distribution unit enables the network access layer to determine the target blockchain network corresponding to the blockchain message according to the network identifier set when receiving the blockchain message carrying the target network identifier, and distribute the blockchain message to the target node instance belonging to the target blockchain network deployed on the node device.
21. An electronic device comprising: processor; a memory for storing processor-executable instructions; The processor implements the method according to any one of claims 1 to 19 by running the executable instructions.
22. A computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the steps of the method according to any one of claims 1 to 19.
Citation Information
Patent Citations
Multi-block chain network data processing method and device and server
CN107453896A
Block chain all-in-one machine, multi-node deployment method and device thereof and storage medium
CN112887160A
