Disclosure of Invention
The invention provides a method, a system and a storage medium for collecting the running state of a main chain and a sub chain of a blockchain in order to solve the problems and combine the actual demands of a alliance chain, thereby realizing the monitoring of the running state of the main chain and the sub chain and improving the running stability and controllability of the blockchain system.
In order to achieve the above purpose, the invention adopts the following technical scheme:
a method for collecting main sub-chain operation state of a block chain, comprising the steps of:
constructing a coalition chain network, wherein the coalition chain network comprises a main chain and more than one sub-chain;
a state collection intelligent contract is deployed on the main chain, and the state collection intelligent contract is used for collecting state data of the sub-chain;
the sub-chain participation organization owns write rights to the state collection intelligent contract on the main chain;
the current sub-chain participation organization submits the state data by calling a state collection intelligent contract of the main chain, and the main chain broadcasts the collected state data of the current sub-chain organization to a blockchain network; other sub-chain participating organizations acquire the state data by listening to the state collection intelligence contract of the backbone.
Preferably, the state data of the sub-chain includes: the sub-chain participation organization quantity and change information, the number of sub-chain link points and change information, the sub-chain running state, the sub-chain intelligent contract quantity and change information.
Further, the sub-chain participation organization has read-write authority for the state collection intelligent contract; when the sub-chain participation organization writes an event to the state collection intelligent contract, the state collection intelligent contract sends a notification; the sub-chain participating organization monitors the state of the main chain to collect the notification sent by the intelligent contract, and acquires the state data of the sub-chain contained in the notification.
Further, when the new sub-link intelligent contract is deployed by the sub-link, submitting a transaction to the state collection intelligent contract of the main chain through the current sub-link participation organization; the state collection intelligent contract of the main chain broadcasts the change information of the sub-chain intelligent contract to a blockchain network; after the other sub-chain participation organizations receive the broadcast, the broadcast content and the fact information are further analyzed and compared, and the situation that the analysis and comparison results are inconsistent is responded.
It is another object of the present invention to provide a main sub-chain operating state collection system of a blockchain, which includes a memory having instructions stored therein and a processor that, by executing the instructions stored in the memory, causes the system to implement the operating state collection method as set forth in any one of the above.
It is a further object of the present invention to provide a computer readable storage medium having instructions stored therein, the execution of which by a system causes the system to implement the method of collecting operating states of any of the above.
The beneficial effects of the invention are as follows:
(1) The invention builds the alliance chain network through the main chain and the sub-chains, and the invention realizes the monitoring of the running state of the main chain and the sub-chains through building the alliance chains, thereby improving the running stability and the running controllability of the block chain system;
(2) From private chains to alliance chains, the corresponding technical difficulties (such as consensus mechanisms, performance problems, privacy protection, etc.) are gradually increased. According to the method, the intelligent contracts are collected through the deployment state, and the main chain is used for monitoring the running state of the sub-chain through the state collection intelligent contracts, so that the legal compliance of the alliance chain can be ensured, and the community trust level is improved;
(3) The main chain of the invention collects the state data of the current sub-chain participation organization of the sub-chain, broadcasts the state data to the block chain network, and maintains the whole block chain network together in a cooperation mode of the main chain and the sub-chain, so that the operation is more flexible;
(4) According to the invention, other sub-chain participation organizations are used for analyzing and comparing the state data monitored by the main chain, and verifying the accuracy of the data, so that the under-chain management is feasible, the efficiency is high, and the cost is low.
Detailed Description
In order to make the technical problems, technical schemes and beneficial effects to be solved more clear and obvious, the invention is further described in detail below with reference to specific embodiments. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
The invention discloses a main sub-chain running state collection method of a block chain, which comprises the following steps of:
constructing a coalition chain network, wherein the coalition chain network comprises a main chain and more than one sub-chain;
a state collection intelligent contract is deployed on the main chain, and the state collection intelligent contract is used for collecting state data of the sub-chain;
the sub-chain participation organization owns write rights to the state collection intelligent contract on the main chain;
the current sub-chain participation organization submits the state data by calling a state collection intelligent contract of the main chain, and the main chain broadcasts the collected state data of the current sub-chain organization to a blockchain network; other sub-chain participating organizations acquire the state data by listening to the state collection intelligence contract of the backbone.
In this embodiment, the sub-chain may be a distributed file system sub-chain, or an industry sub-chain of multiple application fields, or a cross-chain sub-chain of multiple external blockchain networks, etc. The state data of the sub-chain includes: the sub-chain participation organization quantity and change information, the number of sub-chain link points and change information, the sub-chain running state, the sub-chain intelligent contract quantity and change information. The operating state includes block height, transaction number, tps statistics, etc.
The sub-chain participation organization has read-write authority on the state collection intelligent contract; when the sub-chain participation organization writes an event to the state collection intelligent contract, the state collection intelligent contract sends a notification; the sub-chain participating organization monitors the state of the main chain to collect the notification sent by the intelligent contract, and acquires the state data of the sub-chain contained in the notification.
Further, when the new sub-link intelligent contract is deployed by the sub-link, submitting a transaction to the state collection intelligent contract of the main chain through the current sub-link participation organization; the state collection intelligence contract of the backbone broadcasts change information of the sub-chain intelligence contract to a blockchain network. After the other sub-chain participation organizations receive the broadcast, the broadcast content and the fact information are further analyzed and compared, and the situation that the analysis and comparison results are inconsistent is responded. In this embodiment, when a new smart contract is deployed by a sub-chain, an organization (e.g., a deployer) on the sub-chain may make the event (i.e., the sub-chain deploys the new smart contract) known to the main chain by calling the state collection smart contract on the main chain. Invoking the state collection intelligent contract triggers the state collection intelligent contract of the main chain to send out a notification (notification content: a new intelligent contract and information of the contract are deployed on a certain sub-chain), all participating organizations on the sub-chain can receive the notification, so that other participating organizations (i.e. participating organizations on the sub-chain which are not invoking the main chain contract) can check whether the notification is true or not according to the notification content, and information submitted to the main chain by a caller is prevented from being wrong. If not, a chain down arbitration or the like may be initiated.
The sub-chain participating organization has write rights to the state collection intelligent contract. The state collection smart contracts are deployed on the backbone such that the state collection smart contracts are able to collect and record various state data for each sub-chain.
The sub-chain participates in the organization to automatically collect various information of the sub-chain at regular time, when the information is changed (the initial state submitted for the first time also calculates the state change, namely, the state is not changed, for example, the node list is changed, the running state is changed, and the like, all calculate the change), the new state is submitted to the state collection intelligent contract of the main chain through the monitoring account number with the main chain contract submitting authority.
The organization on the main chain collects events sent by the intelligent contract through monitoring the states, acquires various state data, knows state change information and can read the latest state.
Other participating organizations on the sub-chain can monitor events sent by the state collection intelligent contract on the main chain, compare and analyze the monitored state data with sub-chain information collected by the participating organizations, and if the monitored state data is inconsistent with the sub-chain information, complaints can be initiated under the chain. Because the alliance chain is of a real-name system, the under-chain treatment is feasible, the efficiency is high, the cost is low, and the method is a preferable treatment scheme.
An embodiment of the present invention further provides a main sub-chain running state collection system of a blockchain, which includes a memory and a processor, where the memory stores instructions, and the processor executes the instructions stored in the memory to cause the system to implement the running state collection method according to any one of the above.
The system may include one or more computer devices including at least one processor, a communication bus, a memory, and at least one communication interface.
The processor may be a general purpose Central Processing Unit (CPU), microprocessor, application Specific Integrated Circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the present invention.
The Memory may be, but is not limited to, read-Only Memory (ROM) or other type of static storage device that can store static information and instructions, random access Memory (random access Memory, RAM) or other type of dynamic storage device that can store information and instructions, but may also be electrically erasable programmable read-Only Memory (ElectricallyErasable Programmable Read-Only Memory, EEPROM), compact disc read-Only Memory (Compact Disc Read-Only Memory) or other optical disk storage, optical disk storage (including compact disc, laser disc, optical disc, digital versatile disc, blu-ray disc, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer. The memory may be stand alone and coupled to the processor via a bus. The memory may also be integrated with the processor.
Wherein the memory is used for storing program codes for executing the scheme of the invention, and the execution is controlled by the processor. The processor is configured to execute program code stored in the memory.
In a particular implementation, the processor may include one or more CPUs as one embodiment.
In a particular implementation, as one embodiment, a system may include multiple processors, such as a processor and a processor. Each of these processors may be a single-core (single-CPU) processor or may be a multi-core (multi-CPU) processor. A processor herein may refer to one or more devices, circuits, and/or processing cores for processing data (e.g., computer program instructions).
In a specific implementation, as an embodiment, the system may further include an output device and an input device. The output device and the input device are in communication with the processor, respectively. The user input may be accepted in a variety of ways, for example, the input device may be a mouse, a keyboard, a touch screen device, a sensing device, or the like.
The system described above may be a general purpose computer device or a special purpose computer device. In particular implementations, the system may be a desktop, laptop, web server, palmtop (Personal Digital Assistant, PDA), mobile handset, tablet, wireless terminal device, communication device, embedded device, or the like.
One or more software modules are stored in the memory of the system. The system may implement the software modules by means of a processor and program code in a memory to implement the method of collecting operating states described in the above embodiments.
One embodiment of the present invention also provides a computer storage medium having instructions stored therein; the system (which may be a computer device, such as a server) executes the instructions, such as a processor in the computer device, so that the system implements the method of collecting operating states described in the above embodiments.
It should be noted that, in the present specification, each embodiment is described in a progressive manner, and each embodiment is mainly described as different from other embodiments, and identical and similar parts between the embodiments are all enough to be referred to each other. For system embodiments and storage medium embodiments, the description is relatively simple, as it is substantially similar to method embodiments, with reference to the description of method embodiments in part. Also, herein, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element. In addition, it will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program for instructing relevant hardware, where the program may be stored in a computer readable storage medium, and the above storage medium may be a read only memory, a magnetic disk or an optical disk, etc.
While the foregoing description illustrates and describes the preferred embodiments of the present invention, it is to be understood that the invention is not limited to the forms disclosed herein, but is not to be construed as limited to other embodiments, but is capable of use in various other combinations, modifications and environments and is capable of changes or modifications within the scope of the inventive concept, either as described above or as a matter of skill or knowledge in the relevant art. And that modifications and variations which do not depart from the spirit and scope of the invention are intended to be within the scope of the appended claims.