Parallel chain system, consensus method, device and storage medium for lightweight nodes
By using a lightweight parachain system and a zero-knowledge proof consensus method, the deployment challenge of parachain nodes on mobile terminals is solved, achieving efficient consensus and data security while reducing disk space usage.
Patent Information
- Application Number
- CN202210001022.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-04
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2042-01-04
AI Technical Summary
Parachain nodes are difficult to deploy on mobile devices, mainly because they need to store parachain blocks locally, which takes up a lot of disk space and requires multiple consensus nodes, which mobile devices cannot meet.
The system employs a lightweight parachain system. Through a zero-knowledge proof consensus method, lightweight nodes do not need to store all parachain blocks locally. They only maintain the account system and generate and verify parachain transactions through zero-knowledge proof circuits. Consensus can be completed by verifying the zero-knowledge proofs on the main chain.
It enables the deployment of lightweight nodes on personal terminals, reducing disk space usage, improving consensus efficiency, ensuring data security, and meeting the deployment requirements of mobile terminals.
Smart Images

Figure CN114219648B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of computer, and particularly relates to a parallel chain system with lightweight nodes, a consensus method, equipment and a storage medium. BACKGROUND
[0002] In the parallel chain consensus mechanism proposed by the applicant, the parallel chain node synchronizes the parallel chain transaction from the main chain to generate a parallel chain block, and each authorized node of the parallel chain respectively packs (executed on the main chain and the parallel chain respectively) a consensus transaction according to the execution result of the current node of the parallel chain block and sends it to the main chain node. The main chain node records each consensus transaction on the main chain for voting, and if the pre-configuration condition (for example, more than 2 / 3 of the votes are consistent, etc.) is met, the parallel chain block consensus is successful, thereby completing the parallel chain consensus by means of the main chain consensus; the parallel chain node synchronizes the above-mentioned consensus transaction from the main chain and packs and executes it, and then votes locally to complete the parallel chain self-consensus; the parallel chain node synchronizes the above-mentioned consensus transaction from the main chain and packs and executes it, and then votes locally to complete the parallel chain self-consensus.
[0003] In the above-mentioned parallel chain consensus mechanism, it is difficult to arrange the parallel chain node to the mobile terminal, which is mainly due to the fact that the parallel chain node needs to store the parallel chain block locally, which occupies a large disk space, and a plurality of consensus nodes are needed to complete the consensus, and generally the mobile terminal cannot meet the configuration requirements of the parallel chain node. SUMMARY
[0004] In order to solve the above-mentioned problems, the present application provides a parallel chain system with lightweight nodes, a consensus method, equipment and a storage medium, which realizes a lightweight node capable of being deployed on a personal terminal, and the consensus by zero-knowledge proof makes the node not need to store all the parallel chain blocks locally, and the node performs the parallel chain side consensus based on the account system.
[0005] The present application adopts the following technical solutions:
[0006] In a first aspect, a parallel chain system with lightweight nodes is provided, which includes a main chain and a parallel chain. The parallel chain includes a plurality of lightweight nodes, each of which is configured with a transaction database and a temporary block library. Each of the lightweight nodes corresponds to an account system that is maintained. The parallel chain is configured with a zero-knowledge proof circuit and a transaction verification module that is subjected to consensus of the main chain. The transaction verification module is configured to verify parallel chain transactions according to account systems and transaction data of the parallel chain transactions. The zero-knowledge proof circuit includes a transaction signature verification circuit and a state verification circuit configured to verify account states before and after execution of the transactions. The zero-knowledge proof circuit is configured to generate a corresponding zero-knowledge proof according to block data of a parallel chain block and a corresponding public input. The public input is generated based on account system update data. The account system update data is generated according to execution of all parallel chain transactions in the parallel chain block. The account system update data is used to update the account system maintained by the lightweight nodes. The main chain is deployed with a verification Key configured to verify the zero-knowledge proof generated by the zero-knowledge proof circuit.
[0007] In a second aspect, a parallel chain consensus method is provided, which is applicable to the parallel chain system with lightweight nodes as described in the first aspect. The method includes the following steps.
[0008] A first node receives parallel chain transactions synchronized in the parallel chain by other lightweight nodes or parallel chain transactions from the main chain, and verifies the parallel chain transactions by a transaction verification module. The first node stores the received and verified parallel chain transactions in a transaction database of the first node. The first node is one of the lightweight nodes in the parallel chain.
[0009] The first node packs a plurality of parallel chain transactions from the transaction database to generate a first block. The first block is temporarily stored in the temporary block library.
[0010] The first node executes all parallel chain transactions in the first block, and updates an account system maintained by the first node according to an execution result.
[0011] First account system update data is generated according to the execution result of all parallel chain transactions in the first block. The first account system update data is used to update the account system maintained by the first node due to the execution of the parallel chain transactions in the first block.
[0012] First zero-knowledge proof data is constructed using block data of the first block and the first public input data.
[0013] The first node submits the first zero-knowledge proof, the first public input data, and the first block to the main chain.
[0014] The main chain verifies the first zero-knowledge proof according to the verification key corresponding to the parallel chain and the first public input data, and if the verification is passed, the main chain consensus of the first block is completed.
[0015] After the main chain consensus is completed, the first node deletes the first block from the temporary block library thereof.
[0016] The other lightweight nodes in the parallel chain synchronize the first public input data, the first zero-knowledge proof and the verification key from the main chain, and each of the other lightweight nodes verifies the first zero-knowledge proof, and if the verification is passed, updates the account system maintained by each of the other lightweight nodes according to the first public input data.
[0017] Preferably, the parallel chain transactions are each configured with a public transaction fee, and when the first node packs a plurality of parallel chain transactions from the transaction database thereof to generate the first block, the first node packs the parallel chain transactions according to a preset correspondence between the transaction fee and the packing priority.
[0018] Preferably, the zero-knowledge proof circuit computing device of the parallel chain is provided with a corresponding device performance score, and the parallel chain performs zero-knowledge proof data computation by using devices with different device performance scores according to the transaction fee of the parallel chain transaction in the first block.
[0019] Preferably, in the process of submitting the first zero-knowledge proof data and the first public input data to the main chain by the first node, the first zero-knowledge proof data and the first public input data are submitted to the main chain in batches according to the generation order of the first zero-knowledge proof data and the first public input data.
[0020] In a third aspect, a computer device is provided, comprising one or more processors;
[0021] a memory for storing one or more programs,
[0022] When the one or more programs are executed by the one or more processors, the one or more processors perform the method of the second aspect described above.
[0023] In a fourth aspect, a storage medium storing a computer program is provided, and the program is executed by a processor to implement the method of the second aspect described above.
[0024] The beneficial effect of the present application is that the system provided in the embodiment realizes a lightweight node capable of being deployed on a personal terminal, the node only maintains a corresponding account system, and is configured with a transaction database and a temporary block database, parallel chain blocks are generated and deleted after the consensus of the main chain, the latest state of the world account is recorded by maintaining the account system, the local consensus of each lightweight node of the parallel chain only needs to be consistent with the latest state of the account system maintained by itself, and does not need to record all the parallel chain transaction records, and the parallel chain transaction records are stored on the main chain for consensus. The method provided in the embodiment matches the system described above, and the consensus is based on zero-knowledge proof, and the main chain end only needs to verify the zero-knowledge proof to complete the consensus of the parallel chain block. Because the zero-knowledge proof circuit is subjected to the consensus of the main chain, the generated proof is verified to be consistent with the requirements of the consensus of the main chain, and the transaction verification module is also subjected to the consensus of the main chain, all the parallel chain transactions are verified, the public data of the zero-knowledge proof is verified, the safety of the data is ensured, the efficiency of the consensus is greatly improved, and the use of the local disk of the parallel chain lightweight node is reduced. All the lightweight nodes do not need to save all the blocks of the parallel chain to perform the local consensus of the parallel chain, and only need to verify whether the latest state of the account system is consistent. The history records of all the parallel chain transactions can be synchronized through the main chain, and the demand of deploying the parallel chain node by the personal terminal is met. BRIEF DESCRIPTION OF DRAWINGS
[0025] Figure 1 The parallel chain consensus method flowchart of the embodiment 1 of the present application.
[0026] Figure 2 The structure schematic diagram of a computer device of the embodiment 2 of the present application. DETAILED DESCRIPTION
[0027] The present application will be further described in detail and illustrated with specific embodiments and the accompanying drawings. The person skilled in the art can implement the present application based on the description. In addition, the embodiments of the present application involved in the following description are generally only a part of the embodiments of the present application, but not all the embodiments. Therefore, all the other embodiments obtained by the person skilled in the art based on the embodiments in the present application without creative labor should belong to the protection scope of the present application. The methods described in the embodiments of the present application are all the methods mastered by the person skilled in the art, unless otherwise specified.
[0028] Embodiment 1
[0029] As an aspect of the embodiment, a parallel chain system with lightweight nodes is provided, which includes a main chain and a parallel chain, the parallel chain includes a plurality of lightweight nodes, each of the lightweight nodes is configured with a transaction database and a temporary block library, each of the lightweight nodes corresponds to maintain an account system, the account system exists in the form of a Merkle tree, the parallel chain is configured with a zero-knowledge proof circuit and a transaction verification module passed through a consensus of the main chain, the transaction verification module is used to verify parallel chain transactions according to transaction data of the account system and parallel chain transactions, the zero-knowledge proof circuit includes a transaction signature verification circuit and a state verification circuit used to verify account states before and after transaction execution, the zero-knowledge proof circuit is used to generate corresponding zero-knowledge proofs according to block data of parallel chain blocks and corresponding public inputs, the public inputs are generated based on account system update data, the account system update data is generated according to execution of all parallel chain transactions in the parallel chain blocks, the account system update data is used to update the account system maintained by the lightweight nodes, the main chain is deployed with a verification Key used to verify the zero-knowledge proofs generated by the zero-knowledge proof circuit. It should be noted that the parallel chain transactions have been verified by the transaction verification module before the transaction signature verification circuit of the zero-knowledge proof circuit verifies the transactions, and the zero-knowledge proof only makes a complete calculation on a block from the circuit perspective to prevent cheating.
[0030] As another aspect of the embodiment, a parallel chain consensus method is provided, as shown in Figure 1 The method is suitable for the parallel chain system with lightweight nodes described above, and includes the following steps.
[0031] A first node receives parallel chain transactions synchronized in the parallel chain by other lightweight nodes or parallel chain transactions from the main chain, and verifies the parallel chain transactions by a transaction verification module, and stores the received and verified parallel chain transactions in a transaction database of the first node; wherein the first node is one of the lightweight nodes in the parallel chain.
[0032] The first node packs a plurality of parallel chain transactions from the transaction database to generate a first block, and the first block is temporarily stored in the temporary block library.
[0033] The first node executes all parallel chain transactions in the first block, and updates an account system maintained by the first node according to an execution result.
[0034] First account system update data is generated according to the execution result of all parallel chain transactions in the first block, and corresponding first public input data is generated based on the first account system update data; wherein the first account system update data is data used for updating the account system maintained by the first node due to execution of all parallel chain transactions in the first block.
[0035] The first zero-knowledge proof data is constructed using the block data of the first block and the first public input data.
[0036] The first node submits the first zero-knowledge proof and the first public input data to the main chain together with the first block.
[0037] The main chain verifies the first zero-knowledge proof according to the verification key corresponding to the parallel chain and the first public input data, and completes the main chain consensus of the first block if the verification is passed.
[0038] After the main chain consensus is completed, the first node deletes the first block from its temporary block library.
[0039] The other lightweight nodes in the parallel chain synchronize the first public input data, the first zero-knowledge proof and the verification key from the main chain, and all the other lightweight nodes in the parallel chain verify the first zero-knowledge proof, and update the account system maintained by each node according to the first public input data if the verification is passed.
[0040] Further, the parallel chain transactions are all configured with public transaction fees, and when the first node packs a plurality of parallel chain transactions from its transaction database to generate the first block, the first node packs the parallel chain transactions according to the preset correspondence between the transaction fees and the packing priority.
[0041] Further, the zero-knowledge proof circuit computing device of the parallel chain is provided with a corresponding device performance score, and the parallel chain performs zero-knowledge proof data calculation on the devices with different device performance scores according to the transaction fees of the parallel chain transactions in the first block.
[0042] Further, in the process of submitting the first zero-knowledge proof data and the first public input data to the main chain, the first node submits them to the main chain in batches according to the generation order of the first zero-knowledge proof data and the first public input data.
[0043] The principle of the system and method provided by the embodiment is to deploy a plurality of lightweight nodes in the parallel chain, so that the lightweight nodes can use a consensus mode based on zero-knowledge proof in devices such as personal terminals, so that the lightweight nodes do not need to store all historical transaction records, that is, do not need to maintain a database containing all parallel chain blocks locally, and the parallel chain side consensus is implemented by using an account system. Each lightweight node maintains an account system, which records the most trusted state of the parallel chain world account. The account system exists in the form of a Merkle tree. Compared with storing all parallel chain blocks, the disk resources used to maintain a Merkle tree are greatly reduced. The parallel chain side consensus of all lightweight nodes only needs to check whether the latest state of the account system is consistent. The update of the account state of the non-block node is based on the public input of the zero-knowledge proof. The zero-knowledge proof and its public input are obtained from the main chain synchronization. The main chain consensus verifies the zero-knowledge proof generated by the parallel chain. The parallel chain side generates the corresponding zero-knowledge proof through the zero-knowledge proof circuit of the main chain consensus. Since the zero-knowledge proof circuit is consensus, the logic of the circuit is consistent with the consensus requirements of the main chain. The circuit only obtains the proof according to the logic and the input. As long as the zero-knowledge proof passes the verification, it means that the input is consistent with the consensus requirements of the main chain. Therefore, the zero-knowledge proof verification passes, which means that the main chain consensus is successful. The advantage of such consensus is that the parallel chain node only needs to send the public input and the zero-knowledge proof to the main chain. After the verification is successful, the main chain synchronizes the transaction of the consensus block to form a transaction record and chains. The parallel chain synchronizes the zero-knowledge proof and the public input to update the maintained account system. The account system is unified as the consensus, so it is not necessary to store all blocks. The parallel chain node only needs to maintain the account system and a small number of blocks locally, and basically does not need to occupy too much disk.
[0044] Embodiment 2
[0045] A computer device, the device comprising: one or more processors; memory for storing one or more programs, which, when executed by the one or more processors, cause the one or more processors to perform the method of embodiment 1.
[0046] A storage medium storing a computer program, which, when executed by a processor, implements the method of embodiment 1.
[0047] Figure 2 A structural schematic diagram of a device provided by the embodiment.
[0048] As Figure 2As shown, as another aspect, the present application also provides a computer device 100 including one or more central processing units (CPUs) 101 which can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 102 or loaded from a storage section 108 into a random access memory (RAM) 103. In the RAM 103, various programs and data required for the operation of the device 100 are also stored. The CPU 101, the ROM 102, and the RAM 103 are connected to each other through a bus 104. An input / output (I / O) interface 105 is also connected to the bus 104.
[0049] Connected to the I / O interface 105 are an input section 106 including a keyboard, a mouse, etc.; an output section 107 including a display such as a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 108 including a hard disk, etc.; and a communication section 109 including a network interface card such as a LAN card, a modem, etc. The communication section 109 performs communication processing via a network such as the Internet, and a communication processing driver 110 is also connected to the I / O interface 505 as needed. A removable media 111 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is mounted on the driver 110 as needed, so that a computer program read therefrom is installed into the storage section 108 as needed.
[0050] In particular, according to the embodiments disclosed in the present application, the method described in Embodiment 1 above can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product including a computer program tangibly embodied on a machine-readable medium, the computer program including program code for executing the method described in any of the above embodiments. In such embodiments, the computer program can be downloaded and installed from a network by the communication section 109, and / or installed from the removable media 111.
[0051] As still another aspect, the present application also provides a computer-readable storage medium, which can be the computer-readable storage medium included in the apparatus of the above embodiments; or can exist separately from the apparatus and not be assembled into the apparatus. The computer-readable storage medium stores one or more programs which are executed by one or more processors to perform the method described in the present application.
[0052] The computer program product of the present application can be a computer program embodied on a non-transitory computer readable medium. The body of computer readable program code can be any suitable set of instructions stored in a storage medium, which can be run on a computer. The storage medium can be a computer readable storage medium. The storage medium can be a magnetic or optical disk storage such as a CD-ROM or DVD or a magnetic disk or tape. The storage medium can also be a memory such as a RAM or ROM. The storage medium can also be a hard disk drive with non-volatile storage capacity. The storage medium can also be a memory chip. The storage medium can also be a solid state drive. The storage medium can also be a flash memory. The storage medium can also be a portable memory stick. The storage medium can also be a cloud storage. The storage medium can also be a combination of two or more of the above storage media. The storage medium can also be a combination of two or more of the above storage media.
[0053] The units or modules described in the embodiments of the present application can be implemented by software, or can be implemented by hardware. The described units or modules can also be arranged in a processor, for example, each of the units can be a software program arranged in a computer or a mobile smart device, or can be a separately configured hardware device. In some cases, the names of the units or modules do not constitute a limitation on the units or modules themselves.
[0054] The above description is merely preferred embodiments of the present application and a description of the principles of the technology used. Those skilled in the art should understand that the scope of the application described in the present application is not limited to the technical solutions formed by the specific combinations of the above technical features, and should also cover other technical solutions formed by any combination of the above technical features or equivalent features without departing from the concept of the present application. For example, the above features can be replaced with technical features disclosed in the present application (but not limited to) having similar functions to form technical solutions.
Claims
1. A parallel chain system with node lightweight, characterized in that, The parallel chain includes a main chain and a parallel chain, the parallel chain includes a plurality of lightweight nodes, the lightweight nodes configure a transaction database and a temporary block library, each of the lightweight nodes corresponds to maintain an account system, the parallel chain is configured with a zero-knowledge proof circuit and a transaction verification module passed through the main chain consensus, the transaction verification module is used for verifying the parallel chain transaction according to the transaction data of the account system and the parallel chain transaction, the zero-knowledge proof circuit includes a transaction signature verification circuit and a state verification circuit for verifying the account state before and after transaction execution, the zero-knowledge proof circuit generates corresponding zero-knowledge proof according to the block data of the parallel chain block and the corresponding public input, the public input is generated based on account system update data, the account system update data is generated according to the execution of all parallel chain transactions in the parallel chain block, the account system update data is used to update the account system maintained by the lightweight node, and the main chain is deployed with a verification Key for verifying the zero-knowledge proof generated by the zero-knowledge proof circuit.
2. A parallel chain consensus method, characterized by, The method is suitable for the node lightweight parallel chain system in claim 1, and the method comprises: The first node receives the parallel chain transaction synchronized by other lightweight nodes in the parallel chain or the parallel chain transaction from the main chain and verifies the parallel chain transaction through the transaction verification module, and stores the received and verified parallel chain transaction in the transaction database of the first node; Wherein, the first node is one of the lightweight nodes in the parallel chain; The first node packs a plurality of parallel chain transactions from the transaction database to generate a first block, and the first block is temporarily stored in the temporary block library; The first node executes all parallel chain transactions in the first block, and updates the account system maintained by the first node according to the execution result; According to the execution result of all parallel chain transactions in the first block, first account system update data is generated, and corresponding first public input data is generated based on the first account system update data; Wherein, the first account system update data is the data used for updating the account system maintained by the first node due to the execution of all parallel chain transactions in the first block; The first zero-knowledge proof data and the first public input data are submitted to the main chain by the first node; The main chain verifies the first zero-knowledge proof data according to the verification Key corresponding to the parallel chain and the first public input data, and the main chain consensus of the first block is completed when the verification is passed; After the main chain consensus is completed, the first node deletes the first block from the temporary block library; The first public input data, the first zero-knowledge proof data and the verification Key are synchronized from the main chain by other lightweight nodes in the parallel chain, the first zero-knowledge proof data is verified by other lightweight nodes in the parallel chain, and the account system maintained by each node is updated according to the first public input data when the verification is passed. 3. The parallel chain consensus method of claim 2, wherein, The parallel chain transactions are each configured with a public transaction fee, and when the first node packs a first block from the parallel chain transactions in the transaction database of the first node, the first node packs the parallel chain transactions according to a preset correspondence between the transaction fee and the packing priority.
4. The parallel chain consensus method of claim 3, wherein, The zero-knowledge proof circuit computing device of the parallel chain is provided with a corresponding device performance score, and the parallel chain performs zero-knowledge proof data calculation on the devices with different device performance scores according to the transaction fees of the parallel chain transactions in the first block.
5. The parallel chain consensus method of claim 2, wherein, In the process of submitting the first zero-knowledge proof data and the first public input data to the main chain by the first node, the first zero-knowledge proof data and the first public input data are submitted to the main chain in turns according to the generation order of the first zero-knowledge proof data and the first public input data.
6. A computer device, comprising: one or more processors; a memory storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors perform the method of any one of claims 2-5.
7. A storage medium storing a computer program, characterized by comprising: The program is executed by the processor to implement the method of any one of claims 2-5.
Citation Information
Patent Citations
Parallel chain consensus method and device and storage medium
CN110535933A
Parallel chain synchronous transaction verification method and device, and storage medium
CN113793146A