A block synchronization method, related apparatus, medium and program product
By dividing the entire blockchain into multiple intervals and generating proof information, lightweight nodes only need to synchronize a small number of block headers for verification, which solves the problem of high node synchronization overhead and improves synchronization speed and efficiency.
Patent Information
- Application Number
- CN202210039428.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-13
- Publication Date
- 2025-10-24
- Estimated Expiration
- 2042-01-13
AI Technical Summary
When nodes in a blockchain network synchronize the entire blockchain, the overhead is significant, which reduces the synchronization rate and increases the burden on the nodes.
The entire blockchain is divided into N intervals, each containing one or more sequentially connected blocks. Proof information is generated for each interval. Lightweight nodes only need to synchronize the block header and the corresponding proof information for verification, thereby realizing the legality verification of the block header.
It improves the efficiency of block synchronization and verification, and reduces the synchronization overhead and burden of lightweight nodes.
Smart Images

Figure CN116483915B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computers, in particular to the technical field of blockchains, and especially to a block synchronization method based on a blockchain network, a block synchronization device based on a blockchain network, a blockchain node device, a computer readable storage medium, and a computer program product. BACKGROUND
[0002] A blockchain network is a data sharing system supporting distributed storage. The nodes in the blockchain network achieve distributed storage of data contained in blocks by synchronizing the blocks from a full blockchain (e.g., a blockchain containing block headers of all blocks).
[0003] In the prior art, a node in the blockchain network needs to synchronize each block in the full blockchain in the connection order of the blocks to confirm the legitimacy of the blocks in the full blockchain. However, it is found in practice that the overhead of synchronizing each block in the full blockchain in the connection order of the blocks is large, which reduces the block synchronization rate and increases the burden on the node. SUMMARY
[0004] Embodiments of the present application provide a block synchronization method, related device, medium, and program product, which can improve the rate of synchronizing blocks by a node, reduce the overhead required for synchronizing blocks, and reduce the burden on the node.
[0005] In one aspect, the present application provides a block synchronization method based on a blockchain network. The blockchain network includes full nodes and light nodes. The full nodes store a full blockchain. The full blockchain includes N intervals, where N is an integer greater than 1. Each interval includes one or more sequentially connected blocks. Each interval corresponds to a proof information. The proof information is used to prove the correctness of the blocks in the corresponding interval. The light nodes store block headers of part of the blocks in the full blockchain. The method is performed by a light node. The method includes:
[0006] Obtaining a block header of a target block in an i-th interval on the full blockchain, where the proof information of the i-th interval has been successfully verified, i = 1, 2, …, N-1.
[0007] Synchronizing a block header of a target block in an i+1-th interval on the full blockchain from a full node, and synchronizing the proof information of the i+1-th interval.
[0008] Verifying the proof information of the i+1-th interval based on the block header of the target block in the i-th interval and the block header of the target block in the i+1-th interval.
[0009] If the proof information of the i+1th interval is verified successfully, the block header of the target block in the i+1th interval is stored in the storage space.
[0010] In the embodiments of the present application, the blockchain network includes full nodes and light nodes; the full nodes store a full blockchain (e.g., a blockchain including block headers of all blocks), and the full blockchain includes a plurality of sequentially connected blocks divided into N intervals, where N is an integer greater than 1. The light nodes can only synchronize the block header of the target block in the i+1th interval on the full blockchain from the full nodes and the corresponding proof information; then, the light nodes verify the proof information of the i+1th interval based on the block header of the target block in the i th interval and the block header of the target block in the i+1th interval; when the proof information of the i+1th interval is verified successfully, it can be determined that each block in the i+1th interval is valid or legal. In the above scheme, only a small number of block headers can be synchronized from the full blockchain of the full node, such as the block header of the genesis block and the block header of the target block in each interval, so that the validity of the full block header in the full blockchain can be verified based on the small number of block headers, the efficiency of block synchronization and verification is improved, the overhead required for block synchronization of the light node is reduced, and the burden of the light node is reduced.
[0011] On the other hand, the embodiments of the present application provide a block synchronization method based on a blockchain network, the blockchain network includes full nodes and light nodes; the full nodes store a full blockchain, and the full blockchain includes N intervals, where N is an integer greater than 1, each interval includes one or more sequentially connected blocks, and each interval corresponds to a proof information, and the proof information is used to prove the correctness of the blocks in the corresponding interval; the light nodes store the block headers of part of the blocks in the full blockchain; the method is executed by the full nodes, and the method includes:
[0012] receiving a block synchronization request sent by the light node;
[0013] In response to the block synchronization request, the block header of the target block in the i+1th interval on the full blockchain and the proof information of the i+1th interval are returned to the light node, so that the light node verifies the proof information of the i+1th interval based on the block header of the target block in the i th interval and the block header of the target block in the i+1th interval; and after the proof information of the i+1th interval is verified successfully, the light node stores the block header of the target block in the i+1th interval in the storage space of the light node; i=1, 2…N-1.
[0014] In the embodiments of the present application, the full-node in the blockchain network can deploy a block synchronization contract to divide the multiple blocks in the full-blockchain into N intervals, and then generate the proof information of each interval, so that the subsequent light-node can synchronize only a small number of block headers from the full-blockchain, such as the block headers of the target blocks in each interval, and the verification of the proof information of the i+1th interval can realize the verification of the validity of the full-block header in the full-blockchain; the efficiency of block synchronization and verification is improved, the overhead required for block synchronization of the light-node is reduced, and the burden of the light-node is reduced.
[0015] In another aspect, the embodiments of the present application provide a block synchronization device based on a blockchain network, the blockchain network comprising full-nodes and light-nodes; the full-nodes store a full-blockchain, the full-blockchain comprises N intervals, N is an integer greater than 1, each interval comprises one or more sequentially connected blocks, and each interval corresponds to a proof information, the proof information is used to prove the correctness of the blocks in the corresponding interval; the light-nodes store the block headers of part of the blocks in the full-blockchain; the block synchronization device is for the light-nodes, and the device comprises:
[0016] The acquisition unit is configured to acquire the block header of a target block in the i th interval on the full-blockchain, and the proof information of the i th interval has been successfully verified; i = 1, 2, …, N-1;
[0017] The processing unit is configured to synchronize the block header of a target block in the i+1th interval on the full-blockchain from the full-node, and synchronize the proof information of the i+1th interval;
[0018] The processing unit is further configured to verify the proof information of the i+1th interval based on the block header of the target block in the i th interval and the block header of the target block in the i+1th interval;
[0019] The processing unit is further configured to, if the proof information of the i+1th interval is successfully verified, store the block header of the target block in the i+1th interval to the storage space.
[0020] In an implementation manner, the full-blockchain further comprises a genesis block; and the processing unit is further configured to:
[0021] synchronize the block header of the genesis block on the full-blockchain from the full-node;
[0022] when i = 1, verify the proof information of the i th interval based on the block header of the genesis block and the block header of the target block in the i th interval;
[0023] if the proof information of the i th interval is successfully verified, store the block header of the target block in the i th interval to the storage space.
[0024] In an implementation manner, the obtaining unit is configured to obtain the block header of the target block in the ith interval on the full-chain blockchain, and specifically configured to:
[0025] concurrently obtain the block header of the target block in the M intervals from the full-chain node, where M is an integer, M∈[1, N], and the ith interval is any one of the M intervals; or,
[0026] obtain the block header of the target block in the ith interval from the storage space in the light-chain node.
[0027] In an implementation manner, the proof information includes a proof string and output information of a zero-knowledge proof circuit; the proof string is generated by the full-chain node based on a prover public string and a calculation process of the output information calculated by the zero-knowledge proof circuit; the generation of the proof string indicates that the full-chain node has executed the calculation process based on the zero-knowledge proof circuit; the prover public string is a key used by the prover; and the prover includes the full-chain node.
[0028] The output information of the zero-knowledge proof circuit includes: a block header hash of the target block in the ith interval calculated by the zero-knowledge proof circuit, a block header hash of each block in the (i+1)th interval calculated by the zero-knowledge proof circuit, and a circuit check result.
[0029] The circuit check result is used to indicate whether the block header hash calculated by the zero-knowledge proof circuit matches the block header hash of the corresponding block in the full-chain blockchain.
[0030] In an implementation manner, the full-chain blockchain stores a verifier public string; the verifier public string is a key used by the verifier; the verifier includes the light-chain node; and the processing unit is configured to verify the proof information of the (i+1)th interval based on the block header of the target block in the ith interval and the block header of the target block in the (i+1)th interval, and specifically configured to:
[0031] obtain the verifier public string from the full-chain blockchain, and verify the proof string in the proof information of the (i+1)th interval by using the verifier public string to obtain a first verification result;
[0032] read a value of the circuit check result from the output information of the zero-knowledge proof circuit included in the proof information of the (i+1)th interval; and,
[0033] verify the block header hash included in the output information of the zero-knowledge proof circuit in the proof information of the (i+1)th interval based on the block header of the target block in the ith interval to obtain a second verification result.
[0034] If the first verification result is a verification success, the value of the circuit checking result is the preset value, and the second verification result is a verification success, it is determined that the verification result corresponding to the i+1 interval is a verification success.
[0035] When the value of the circuit checking result is the preset value, the circuit checking result is used to indicate that the block header hash obtained by using the zero-knowledge proof circuit matches the block header hash of the corresponding block in the full-block chain.
[0036] In an implementation manner, when the processing unit verifies the block header hash contained in the output information of the zero-knowledge proof circuit in the proof information of the i+1 interval according to the block header of the target block in the i interval, and obtains the second verification result, the processing unit is specifically configured to:
[0037] obtain the block header hash of the first reference block in the i interval from the proof information of the i interval; the first reference block refers to a block in the i interval whose block height is 1 less than the block height of the target block in the i interval;
[0038] calculate the block header hash of the target block in the i interval according to the block header hash of the first reference block;
[0039] compare the calculated block header hash of the target block in the i interval with the block header hash of the target block in the i interval contained in the output information of the zero-knowledge proof circuit in the proof information of the i interval, to obtain a first comparison result;
[0040] obtain the block header hash of the second reference block in the i+1 interval from the proof information of the i+1 interval; the second reference block refers to a block in the i+1 interval whose block height is 1 less than the block height of the target block in the i+1 interval;
[0041] calculate the block header hash of the target block in the i+1 interval according to the block header hash of the second reference block;
[0042] compare the calculated block header hash of the target block in the i+1 interval with the block header hash of the target block in the i interval contained in the output information of the zero-knowledge proof circuit in the proof information of the i+1 interval, to obtain a second comparison result;
[0043] If the first comparison result is a comparison success, and the second comparison result is a comparison success, it is determined that the second verification result is a verification success.
[0044] In an implementation manner, the processing unit is further configured to:
[0045] In response to the transaction query event for the target transaction, a transaction query request is sent to the full-node, the transaction query request containing the block height corresponding to the target transaction, so that the full-node determines the block to which the target transaction belongs based on the block height corresponding to the target transaction;
[0046] The block header of the block to which the target transaction belongs and the proof information of the i+1th interval corresponding to the block to which the target transaction belongs returned by the full-node in response to the transaction query request are received;
[0047] Based on the block header of the block to which the target transaction belongs and the proof information of the i+1th interval, it is queried whether the target transaction exists in the block to which the target transaction belongs, and a query result is obtained;
[0048] The query result is output.
[0049] In an implementation manner, the transaction query event is an event generated when the transaction query information sent by the client is obtained; the transaction query information includes a transaction hash of the target transaction and a Merkle path of the target transaction; the processing unit is configured to, when the target transaction is queried based on the block header of the block to which the target transaction belongs and the proof information of the i+1th interval, and a query result is obtained, specifically configured to:
[0050] The block header hash of the third reference block is obtained from the output information of the zero-knowledge proof circuit in the proof information of the i+1th interval, and the block header hash of the block to which the target transaction belongs is calculated according to the block header hash of the third reference block; the third reference block refers to a block with a block height smaller than that of the block to which the target transaction belongs by 1 in the i+1th interval;
[0051] If the calculated block header hash of the block to which the target transaction belongs is the same as the block header hash of the block to which the target transaction belongs in the output information of the zero-knowledge proof circuit in the proof information of the i+1th interval, a Merkle root is generated based on the transaction hash of the target transaction and the Merkle path of the target transaction;
[0052] If the generated Merkle root exists in the block header of the block to which the target transaction belongs, a query result is generated, and the query result is used to indicate that the target transaction exists in the block to which the target transaction belongs.
[0053] In an implementation manner, the target block refers to a block with the largest block height in the interval.
[0054] In the embodiments of the present application, the blockchain network includes full nodes and light nodes; the full nodes store a full blockchain (e.g., a blockchain including block headers of all blocks), and the full blockchain includes a plurality of sequentially connected blocks divided into N intervals, where N is an integer greater than 1. The light nodes can only synchronize the block header of a target block in the i+1th interval on the full blockchain and the corresponding proof information from the full nodes; then, the light nodes verify the proof information of the i+1th interval based on the block header of the target block in the ith interval and the block header of the target block in the i+1th interval; when the proof information of the i+1th interval is verified successfully, it is determined that each block in the i+1th interval is valid or legal. In the above scheme, only a small number of block headers, such as the block header of the genesis block and the block header of the target block in each interval, are synchronized from the full blockchain of the full nodes, and the validity of the full block header in the full blockchain can be verified based on the small number of block headers, thereby improving the efficiency of block synchronization and verification, reducing the overhead required for block synchronization of the light nodes, and reducing the burden of the light nodes.
[0055] In another aspect, the embodiments of the present application provide a block synchronization device based on a blockchain network, the blockchain network including full nodes and light nodes; the full nodes store a full blockchain, and the full blockchain includes N intervals, where N is an integer greater than 1, each interval includes one or more sequentially connected blocks, and each interval corresponds to a proof information, which is used to prove the correctness of the blocks in the corresponding interval; the light nodes store the block headers of part of the blocks in the full blockchain; the block synchronization device is a full node, and the device includes:
[0056] a receiving unit configured to receive a block synchronization request sent by a light node;
[0057] a processing unit configured to, in response to the block synchronization request, return the block header of a target block in the i+1th interval on the full blockchain and the proof information of the i+1th interval to the light node, so that the light node verifies the proof information of the i+1th interval based on the block header of the target block in the ith interval and the block header of the target block in the i+1th interval; and after the proof information of the i+1th interval is verified successfully, the light node stores the block header of the target block in the i+1th interval in the storage space of the light node; i=1, 2, …, N-1.
[0058] In an implementation manner, the processing unit is further configured to:
[0059] obtain a zero-knowledge proof circuit generated based on a to-be-proved proposition, the to-be-proved proposition being used to indicate verification of the correctness of the block headers of part of the blocks in the full blockchain;
[0060] deploying a block synchronization contract, and in the process of deploying the block synchronization contract, dividing a plurality of sequentially connected blocks in a full-blockchain into N intervals;
[0061] The block synchronization contract is called to set the state of the i+1th interval to an exclusive state, and the block header hash of each block in the i+1th interval and the block header hash of the target block in the i th interval are extracted from the full-blockchain; the target block in the i th interval refers to the block with the highest height in the i th interval;
[0062] According to the zero-knowledge proof circuit, the block header hash of each block in the i+1th interval and the block header hash of the target block in the i th interval are verified to generate the proof information of the i+1th interval;
[0063] The proof information of the i+1th interval is stored in the full-blockchain.
[0064] In an implementation manner, the proof information of the i+1th interval includes: output information of the zero-knowledge proof circuit; and the processing unit is specifically configured to, when generating the proof information of the i+1th interval by verifying the block header hash of each block in the i+1th interval and the block header hash of the target block in the i th interval according to the zero-knowledge proof circuit, specifically configured to:
[0065] The block header hash of the first reference block in the i th interval is obtained from the full-blockchain, and the block header hash of the target block in the i th interval is calculated according to the block header hash of the first reference block; the first reference block refers to the block with a height smaller than the target block in the i th interval by 1;
[0066] For each block in the i+1th interval, the block header hash of each block is calculated by using the block header hash of the previous block, to obtain the block header hash of each block in the i+1th interval;
[0067] The calculated block header hash of the target block in the i th interval and the calculated block header hash of each block in the i+1th interval are checked to generate a circuit checking result;
[0068] The output information of the zero-knowledge proof circuit includes: the block header hash of the target block in the i th interval calculated by using the zero-knowledge proof circuit, the block header hash of each block in the i+1th interval calculated by using the zero-knowledge proof circuit, and the circuit checking result.
[0069] In an implementation manner, the processing unit is specifically configured to:
[0070] compare the block header hash of the target block in the i-th interval calculated by the zero-knowledge proof circuit with the block header hash of the target block in the i-th interval extracted from the full-blockchain;
[0071] and compare the block header hash of each block in the i+1-th interval calculated by the zero-knowledge proof circuit with the block header hash of the corresponding block in the i+1-th interval extracted from the full-blockchain;
[0072] If the comparison results are all successful, the circuit checking result is generated, and the value of the circuit checking result is a preset value, which is used to indicate that the block header hash calculated by the zero-knowledge proof circuit matches the block header hash of the corresponding block in the full-blockchain.
[0073] In an implementation manner, the proof information corresponding to the i+1-th interval further includes a proof string, and the processing unit is further configured to:
[0074] obtain a key generation algorithm, and generate a prover public string and a verifier public string according to the key generation algorithm; the prover public string is a key used by the prover, and the prover includes the full-node; the verifier public string is a key used by the verifier, and the verifier includes the light-node;
[0075] store the verifier public string to the full-blockchain; and
[0076] generate a proof string for the calculation process of the output information calculated by the zero-knowledge proof circuit based on the prover public string; the generation of the proof string indicates that the full-node has executed the calculation process based on the zero-knowledge proof circuit.
[0077] In an implementation manner, the processing unit is further configured to:
[0078] If it is detected that the proof information of the i+1-th interval has been generated, the exclusive state of the i+1-th interval is released; or
[0079] If the duration of the i+1-th interval in the exclusive state is greater than a duration threshold since the i+1-th interval is set to the exclusive state, the exclusive state of the i+1-th interval is released.
[0080] In the embodiments of the present application, the full-node in the blockchain network can deploy a block synchronization contract to divide the multiple blocks in the full-blockchain into N intervals, and then generate the proof information of each interval, so that the subsequent light node can synchronize only a small number of block headers from the full-blockchain, such as the block headers of the target blocks in each interval. The proof information of the i+1 interval is verified to realize the verification of the validity of the full-block header in the full-blockchain. The efficiency of block synchronization and verification is improved, the overhead required for block synchronization of the light node is reduced, and the burden of the light node is reduced.
[0081] In another aspect, the present application provides a blockchain node device, which comprises:
[0082] a processor for loading and executing a computer program;
[0083] a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the above-mentioned block synchronization method based on the blockchain network.
[0084] In another aspect, the present application provides a computer readable storage medium, which stores a computer program, and the computer program is loaded and executed by the processor to implement the above-mentioned form generation method.
[0085] In another aspect, the present application provides a computer program product or a computer program, which comprises computer instructions stored in a computer readable storage medium. The processor of the blockchain node device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to make the blockchain node device execute the above-mentioned block synchronization method based on the blockchain network. BRIEF DESCRIPTION OF DRAWINGS
[0086] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed in the embodiments or the prior art description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained without creative labor on the basis of these drawings.
[0087] Figure 1a A structure diagram of a blockchain provided by an exemplary embodiment of the present application is shown;
[0088] Figure 1b A structure diagram of a data sharing system provided by an exemplary embodiment of the present application is shown;
[0089] Figure 1cAn architecture diagram of a double-layer blockchain network provided by one example embodiment of the present application is shown;
[0090] Figure 2 A flowchart of a block synchronization scheme based on a blockchain network provided by one example embodiment of the present application is shown;
[0091] Figure 3 A structure diagram of a zero-knowledge proof circuit provided by one example embodiment of the present application is shown;
[0092] Figure 4 A diagram showing that a plurality of blocks contained in a full-amount blockchain are divided into N intervals provided by one example embodiment of the present application is shown;
[0093] Figure 5 A diagram showing the calculation process of a zero-knowledge proof circuit provided by one example embodiment of the present application is shown;
[0094] Figure 6 A flowchart of a block synchronization method based on a blockchain network provided by one example embodiment of the present application is shown;
[0095] Figure 7a A diagram showing that a light node concurrently acquires block headers of target blocks in an interval provided by one example embodiment of the present application is shown;
[0096] Figure 7b A diagram showing that a light node concurrently acquires block headers of target blocks in an interval provided by one example embodiment of the present application is shown;
[0097] Figure 8 A diagram showing that each interval is serially verified for proof information provided by one example embodiment of the present application is shown;
[0098] Figure 9 A diagram showing that block headers of each block are sequentially stored provided by one example embodiment of the present application is shown;
[0099] Figure 10 A flowchart of a block synchronization method based on a blockchain network provided by one example embodiment of the present application is shown;
[0100] Figure 11 A structure diagram of a block synchronization device based on a blockchain network provided by one example embodiment of the present application is shown;
[0101] Figure 12 A structure diagram of a block synchronization device based on a blockchain network provided by one example embodiment of the present application is shown;
[0102] Figure 13 Fig. 1 shows a structural schematic diagram of a blockchain node device according to an example embodiment of the present application. DETAILED DESCRIPTION
[0103] The technical solutions in the embodiments of the present application will be clearly and completely described with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the present application.
[0104] The embodiments of the present application relate to a blockchain. The blockchain is the basis of blockchain technology. The blockchain is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithm. The blockchain is essentially a decentralized database, which is a series of data blocks associated by using cryptographic methods. Each data block contains information of a batch of network transactions, which is used to verify the validity (anti-fake) of the information and generate the next block. A structural schematic diagram of a blockchain can be seen from Figure 1a As shown in Figure 1a , the blockchain 101 is composed of a plurality of blocks. The first block of the blockchain is called the genesis block (which can be referred to as the genesis block). The genesis block includes a block header and a block body. The block header stores an input information characteristic value, a version number, a timestamp, and a difficulty value. The block body stores input information. The next block of the genesis block takes the genesis block as the parent block. The next block also includes a block header and a block body. The block header stores an input information characteristic value of the current block, a block header characteristic value of the parent block, a version number, a timestamp, and a difficulty value. This is followed by the next block, so that the block data stored in each block in the blockchain is associated with the block data stored in the parent block, thereby ensuring the security of the input information in the block.
[0105] The blockchain can be maintained by a blockchain node included in a blockchain network. The blockchain network can be understood as a data sharing system, which is a system for sharing data between blockchain nodes. An example structural schematic diagram of the data sharing system can be seen from Figure 1b ; as Figure 1bAs shown, the data sharing system can include a plurality of blockchain nodes 101, each of which can be a server or a terminal (e.g., a client running in a terminal) accessing the blockchain network. The specific form of the blockchain node 101 is not limited here. Each blockchain node 101 in the blockchain network has a corresponding node identifier, and each blockchain node 101 in the blockchain network can store the node identifiers of other blockchain nodes 101 in the blockchain network, so as to subsequently broadcast the generated block to other blockchain nodes 101 in the data sharing system according to the node identifiers of other blockchain nodes 101. Each blockchain node 101 can maintain a node identifier list, and store the node name and node identifier in the node identifier list; where the node identifier list can refer to Table 1:
[0106] Table 1
[0107] Node name Node identification Node 1 117.114.151.174 Node 2 117.116.189.145 … … Node X (X is a positive integer) xx.xxx.xxx.xxx
[0108] As shown in Table 1, the node identifier can be an IP (Internet Protocol) address and any other information that can be used to identify the node; for example, the node identifier can also be a binary sequence code (such as 110001110), and Table 1 only takes the IP address as an example for description. Each blockchain node in the blockchain network maintains a node identifier list, and when any consensus node (e.g., a blockchain node with consensus function) in the blockchain network adds a consensus passed block to the full blockchain, other nodes in the blockchain network obtain the node identifier of the any consensus node from the maintained node identifier list, and synchronize the consensus passed block from the full blockchain according to the node identifier of the any consensus node, to realize synchronization of data in the blockchain network. In the present embodiment, the blockchain containing the block header of all blocks provided by the consensus node is referred to as the full blockchain, which is described herein.
[0109] The full amount node in the blockchain network provided by the embodiments of the present application is a node that stores a full amount blockchain. That is, the full amount node is a node that needs to synchronize all blocks contained in the full amount blockchain in sequence from the genesis block of the full amount blockchain. For example, the full amount node can be a consensus node in the blockchain network that has a function of consensus on blocks, and the consensus node contains all block headers of the full amount blockchain and the block body corresponding to each block header. For another example, the full amount node can also be an SPV node (Special Purpose Vehicle) in the blockchain network, also known as a business node. The SPV node is a node that saves the block header of each block in the full amount blockchain. Specifically, the SPV node stores the full amount block header in the full amount blockchain and has the right to obtain part of the block body (or transaction data), and does not store the complete full amount blockchain.
[0110] In actual application, the full amount node in the blockchain network needs to undertake a large amount of business functions. For example, the full amount node is a business node, and the business node may need to undertake a large amount of query requests. For example, in the invoice business, the query request can be sent by the client to the business node to request to query whether the invoice transaction exists in the full amount blockchain. However, when the business node queries whether the transaction is chained, it does not need to query each block in the full amount blockchain, and thus the business node does not need to download all the blocks in the full amount blockchain. Therefore, if the business function of querying the existence of the transaction can be separated from the full amount node that undertakes a large amount of business functions (or other business functions that do not need all the block headers in the full amount blockchain), the burden of the full amount node can be reduced to a certain extent, and the cost of the full amount node can be saved. Further, when the full amount node cannot synchronize the block at a certain block height from the full amount blockchain, it is confirmed that the block header of the block is a legal block header. Only when the block header hash of the previous block header contained in the block header is verified, it can be determined that the block header of the block is legal. This makes the full amount node need to synchronize all the blocks in sequence from the genesis block of the full amount blockchain even if it only undertakes the business function of querying the existence of the transaction (or other business functions that do not need all the blocks). Therefore, if the node that undertakes the business function of querying the existence of the transaction does not need to synchronize all the block headers from the full amount blockchain, the storage cost of the node can be greatly reduced, and the business processing efficiency can be improved.
[0111] Based on the foregoing description of the full amount node, the embodiment of the present application provides a block synchronization scheme based on a block chain network. In the block chain network of the present scheme, a light node is introduced, that is, the block chain network involved in the embodiment of the present application includes a light node and the aforementioned full amount node. The light node in the block chain network can be used to undertake some business functions that do not require synchronization of full amount data (such as all block headers in the full amount block chain). For example, the light node can be used to undertake the business function of querying the existence of a transaction. This can achieve the separation of part of the business function from the full amount node (such as a business node), thereby reducing the burden of the full amount node. Moreover, compared with the full amount node, the light node does not need to synchronize all blocks or block headers in the full amount block chain. Instead, the light node only needs to synchronize a small part of the block headers in the full amount block chain to verify the legality of the full amount data (such as all data in the full amount block chain) in the block chain network, thereby greatly reducing the storage cost and the overhead of synchronizing blocks of the light node. The effectiveness can be referred to as correctness or legality. When the block header of a block includes the block header hash of the previous block, it means that the block header of the block is legal (or effective, correct), thereby determining that the connection order of the block in the full amount block chain is correct, and determining that the block data in the block body of the block is safe.
[0112] The light node mentioned in the embodiment of the present application can be a terminal connected to the block chain network or a server connected to the block chain network. The terminal can include, but is not limited to, a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a portable computer, a mobile Internet device (Mobile Internet Devices, MID for short), a smart television, a vehicle-mounted device, a head-mounted device, and other smart devices that can perform touch screen operations. The server can include, but is not limited to, a data processing server, a Web server, an application server, and other devices with complex computing capabilities. The embodiment of the present application does not limit the specific type of the light node in the block chain network, and this is specifically explained.
[0113] To better understand the light node and full node in the blockchain network, the types of blockchain network containing light nodes are introduced as follows. The light node provided in the embodiments of the present application can belong to the node in any sub-network in a double-layer or multi-layer network; the "layer" here refers to the number of sub-networks contained in the blockchain network; the division of sub-networks can be for the consideration of business needs, communication connection, security, etc.; the mutual access between the blockchain nodes in the same sub-network is guaranteed by the consensus mechanism, while the mutual access between the blockchain nodes in different sub-networks needs to additionally join identity management and / or network control. For example, when the blockchain is applied in some scenarios, such as a ticket business scenario, a data storage scenario of government or commercial institutions, etc.; in these scenarios, not all nodes in the blockchain network have enough resources and necessity to become nodes for executing blockchain consensus. And for the consideration of data security, the universal data peer-to-peer blockchain deployment mode is not suitable for the important data involved in the blockchain system. In order to adapt to the business needs (such as internal and external networks, business networks, office networks, etc.) and further improve the security and confidentiality of data, a double-layer chain can be used, that is, a double-layer network architecture of "witness sub-network-consensus sub-network" is formed through a P2P (Peer to Peer, point-to-point) network to improve the security of data; the P2P network is a point-to-point connection network, and each node in the point-to-point connection is called a peer node. The P2P network is based on a specific network protocol, so that the peer nodes do not need a central node to maintain the network state, and each node maintains the node state of the whole network and the connection state with adjacent nodes through broadcast interaction with adjacent nodes.
[0114] Figure 1c An architecture diagram of a double-layer blockchain network provided in an example embodiment of the present application is shown; as Figure 1cAs shown, the blockchain network includes a witness subnetwork and a consensus subnetwork, and the lightweight node provided in the embodiment of the present application can access the witness subnetwork. Wherein: ① The witness subnetwork includes a business node and / or a lightweight node. The business node in the witness subnetwork mainly performs business execution (such as the lightweight node is used to query whether a transaction is chained), does not perform accounting consensus, and obtains a block header and / or part of the authorized visible block data from the consensus subnetwork through identity authentication. ② The consensus subnetwork is the core network in the blockchain network, which is used for accounting consensus of the blockchain network. The consensus subnetwork includes one or more consensus nodes (or called accounting nodes), and the consensus node is used for consensus of the block to realize chaining of the block. Further, the witness subnetwork and the consensus subnetwork can interact through the routing agent network (or called routing boundary network) between the two; that is, the routing agent network is used for network isolation of the witness subnetwork and the consensus subnetwork; the routing agent network includes one or more routing agent nodes, so that the routing agent node can forward the data sent by the business node in the witness subnetwork to the consensus node in the consensus subnetwork, which can improve the security of the data in the consensus subnetwork.
[0115] It is worth noting that in the above-mentioned double-layer network structure, the full-amount node mentioned above can be a business node in the witness subnetwork, at this time the lightweight node and the full-amount node (such as the business node) belong to the same network (such as the witness subnetwork); the full-amount node can also be a consensus node in the consensus subnetwork, at this time the lightweight node and the full-amount node (such as the consensus node) belong to different subnetworks, and the data interaction (such as synchronization of the block header by the lightweight node from the full-amount node) between the lightweight node and the full-amount node needs to pass through the routing agent network between the witness subnetwork and the consensus subnetwork, and is realized by the routing agent node in the routing agent network. The embodiment of the present application does not limit whether the full-amount node is a business node in the witness subnetwork or a consensus node in the consensus subnetwork, which is explained herein. Wherein, when the full-amount node is a business node, the full-amount node and the lightweight node belong to the same subnetwork (i.e. the witness subnetwork), at this time the blockchain network is understood as a single-layer network; for example, Figure 1b The blockchain network shown is a single-layer blockchain network, and the blockchain nodes in the single-layer blockchain network can realize secure access and data synchronization through a consensus mechanism. The embodiment of the present application does not limit the type of blockchain network to which the lightweight node belongs, which is explained herein.
[0116] In specific implementation, the block synchronization scheme based on the blockchain network provided by the embodiments of the present application is implemented based on zero-knowledge proof (zkp) technology, specifically, is implemented based on Zero-Knowledge Succinct Non-Interactive Argument of Knowledge (zk-snark) technology. The zero-knowledge proof is a protocol involving two or more parties, that is, a series of steps taken by two or more parties to complete a task. For example, the two parties involved in the zero-knowledge proof can include a prover (such as an object proving the correctness of a proposition) and a verifier (such as an object verifying whether the proof provided by the prover for a proposition is correct). In the embodiments of the present application, the prover can include a full-node (i.e., a node containing a full blockchain) in the blockchain network, and the verifier can include a light node (i.e., a node containing only the block header of part of the blocks in the full blockchain) in the blockchain network. In the process of a zero-knowledge proof, the prover can interact with the verifier multiple times without providing any useful information to the verifier, so that the verifier believes the correctness of a proposition. The zero-knowledge succinct non-interactive argument of knowledge is also a protocol involving two or more parties, which can judge the correctness of a proposition. However, unlike the zero-knowledge proof, the zero-knowledge succinct non-interactive argument of knowledge achieves the goal of non-interactive at the cost of certain controversiality. In other words, in the process of a zero-knowledge succinct non-interactive argument of knowledge, the prover and the verifier only interact once to judge the correctness of a proposition.
[0117] The embodiments of the present application implement the block synchronization scheme based on the blockchain network by using the zero-knowledge succinct non-interactive argument of knowledge technology, specifically, by using the zero-knowledge succinct non-interactive argument of knowledge technology, the light node (i.e., the verifier) verifies that: ① the correctness of the downloaded block header; and ② when h i ,h j is the block height of two adjacent downloaded block headers, the h i ,h jThe block header between the block heights is correct, i and j are values corresponding to two block heights in the full-chain, and i is greater than j. That is, through the zero-knowledge succinct non-interactive knowledge argument technology, the prover (such as a full node) sends data (such as the block header of part of the blocks in the full-chain) to the verifier (such as a light node) to make the verifier believe the legitimacy of the full-chain data in the full-chain. The following will introduce the block synchronization scheme provided by the embodiments of the present application in combination with the operation principle of the zero-knowledge succinct non-interactive knowledge argument, which can be divided into four steps in principle, including:
[0118] 1) The full node in the blockchain network can convert the proposition to be proved into a zero-knowledge proof circuit. The proposition to be proved can be a proposition to be judged or verified between the prover and the verifier. Specifically, the operation logic corresponding to the proposition to be proved can be expressed by using an operator to obtain the zero-knowledge proof circuit corresponding to the proposition to be proved.
[0119] 2) The full node in the blockchain network generates public parameters, a prover key and a verifier key for the proposition to be proved using a generation algorithm. Since the generated prover key and verifier key are public (any node in the blockchain network can obtain them), the embodiments of the present application refer to the prover key as a prover public string and the verifier key as a verifier public string, which will not be limited in the following description. The public parameter is a string randomly generated by the generation algorithm and cannot be leaked. The public parameter has an important influence on the security of the proof process.
[0120] 3) The full node in the blockchain network generates proof information through the prover key and the zero-knowledge proof circuit (i.e. the R1CS circuit converted from the proposition to be proved).
[0121] 4) The light node in the blockchain network verifies the proof information generated by the full node using the verifier key; when the proof information is verified successfully, the verifier determines that the data provided by the prover is valid, such as the light node determining that the block header of the part of the blocks synchronized from the full-chain of the full node is legal; otherwise, when the proof information is verified unsuccessfully, the verifier determines that the data provided by the prover is invalid, such as the light node determining that the block header of the block synchronized from the full-chain of the full node is illegal.
[0122] In steps 2)-4), the generation algorithm included in the zero-knowledge succinct non-interactive knowledge argument can include: a key generation algorithm, a prover algorithm, and a verifier algorithm. Among them: the key generation algorithm can generate a prover key and a verifier key based on public parameters; the prover algorithm can generate proof information for the proposition to be proved based on the prover key; the verifier algorithm can verify the proof information generated by the prover based on the verifier key to obtain a verification result, which can also be referred to as a circuit check result.
[0123] It should be noted that the above is only a simple introduction to the operation principle of the zero-knowledge succinct non-interactive knowledge argument; in actual application scenarios, the operation principle of the zero-knowledge succinct non-interactive knowledge argument also includes other contents. For example, for the related introduction of the three algorithms included in the zero-knowledge succinct non-interactive knowledge argument, the above is only an exemplary description; for the process of generating a key by the key generation algorithm, in the process of generating a prover key and a verifier key based on public parameters by the key generation algorithm, in addition to the public parameters, the program information for generating the key is also involved; the embodiments of the present application do not make a detailed description here.
[0124] Based on the above description of the zero-knowledge succinct non-interactive knowledge argument, the implementation process of the prover (such as a full-node) generating proof information, the implementation process of the verifier (such as a light node) verifying the proof information generated by the prover, and the implementation process of the verifier executing a business function (such as executing a business function of querying the existence of a transaction) will be described in detail below with reference to different embodiments and the accompanying drawings. Figure 2 The implementation process of a full-node in a blockchain network generating proof information is described. Figure 2 FIG. 1 shows a flowchart of a block synchronization scheme based on a blockchain network according to an exemplary embodiment of the present application; the block synchronization scheme can be executed by a full-node in the blockchain network, and the scheme can specifically include but is not limited to steps S201-S204:
[0125] S201: Obtain a zero-knowledge proof circuit generated based on a proposition to be proved.
[0126] As described in the foregoing, the embodiments of the present application are based on the zero-knowledge succinct non-interactive argument of knowledge technology, so that the light node can verify the correctness of the block header of the downloaded block and the correctness of the block header between two adjacent blocks of the downloaded block header only in the case of synchronizing a small number of block headers from the full-block chain. Based on this, the proposition to be proved involved in the embodiments of the present application can be simply summarized as verifying the correctness of the block header of part of the blocks in the full-block chain and the correctness of each block header between the block headers of the part of the blocks. Then, when the full-node in the block chain network initializes the zero-knowledge proof circuit based on the proposition to be proved, such as expressing the operation logic corresponding to the proposition to be proved by using one or more operation methods, the initialization of the zero-knowledge proof circuit can be realized, that is, the zero-knowledge proof circuit corresponding to the proposition to be proved is obtained. The operation logic of the zero-knowledge proof circuit can be simply expressed as: for each block header in the block header of part of the blocks in the full-block chain, calculating the block header hash of each block header by using the block header of the previous block; then, comparing the calculated block header hash of each block header with the input information of the zero-knowledge proof circuit (that is, the block header hash of the part of the blocks obtained from the full-block chain); and generating a circuit check result according to the comparison result.
[0127] Among them, the zero-knowledge proof circuit can be referred to as an arithmetic circuit (Rank One Constrain System, R1CS); an exemplary structure of a zero-knowledge proof circuit can be referred to as Figure 3 The zero-knowledge circuit is composed of some addition gates, multiplication gates and some constant gates, such as Figure 3 As shown in the zero-knowledge proof circuit, it includes two multiplication gates and one addition gate. In actual application, after inputting the input information into the zero-knowledge proof circuit, the operation of each gate included in the zero-knowledge proof circuit can be performed in sequence to obtain the output information of the zero-knowledge proof circuit; the output information of the zero-knowledge proof circuit can be simply understood as the answer obtained by solving the proposition to be proved. As shown in Figure 3 The input information is a, b, and c, the addition gate included in the zero-knowledge proof circuit can add a and b to obtain a+b, and the multiplication gate can multiply b and c to obtain b*c; then, the multiplication gate is used to multiply a+b and b*c to obtain the output information (a+b)*b*c. It should be noted that some common calculation logic, such as calculation expression and calculation hash value, can be represented as a zero-knowledge proof circuit.
[0128] It should be noted that after the zero-knowledge proof circuit is initialized based on the zero-knowledge succinct non-interactive argument of knowledge technology, the key generation algorithm of the zero-knowledge succinct non-interactive argument of knowledge technology can also be obtained, and the prover public string for the prover and the verifier public string for the verifier can be generated according to the key generation algorithm; wherein the prover public string is the key used by the prover, and the verifier public string is the key used by the verifier. Further, the generated verifier public string is stored in the full-block chain to realize the on-chain of the verifier public string. And the initialized zero-knowledge proof circuit and the prover public string are disclosed off-chain, such as putting the zero-knowledge proof circuit and the prover public string into a certain website page, so that any full node in the blockchain network that has the permission and needs to obtain the zero-knowledge proof circuit and / or the prover public string can open the website page through the website page link address (such as website address) to obtain the zero-knowledge proof circuit and / or the prover public string.
[0129] S202: deploy a block synchronization contract, and in the process of deploying the block synchronization contract, divide a plurality of sequentially connected blocks in the full-block chain into N intervals.
[0130] The block synchronization contract can be a contract named fastsync. In the process of deploying the block synchronization contract in the blockchain network, the number of intervals can be set in the process of deploying the block synchronization contract in the full node in the blockchain network. In this way, the full node can call the block synchronization contract to divide a plurality of blocks in the full-block chain that are linked after the genesis block into the number of intervals. For example, in the process of deploying the block synchronization contract, assuming that the number of intervals set is N, N is an integer greater than 1, it is determined that the plurality of blocks in the full-block chain that are linked after the genesis block are evenly divided into N intervals, and each interval contains one or more sequentially connected blocks. Optionally, in the process of deploying the block synchronization contract in the full node, the number of intervals can not be set, but the number of blocks in each interval (or interval capacity) can be set. In this way, the plurality of blocks in the full-block chain that are linked after the genesis block can be divided according to the number of blocks in each interval set to obtain a plurality of intervals. For example, assuming that the number of blocks in each interval is set to 3, and the number of blocks in the full-block chain that are linked after the genesis block is 9 (i.e., the block height of the full-block chain is 10), the 9 blocks in the full-block chain that are linked after the genesis block can be evenly divided into 3 intervals.
[0131] An exemplary schematic diagram of dividing a plurality of blocks contained in a full-block chain into N intervals can be seen in Figure 4 ; such as Figure 4As shown, assuming that the number of blocks in each interval, i.e., interval capacity, is set to 3 during the process of deploying the block synchronization contract, then every three blocks in the plurality of blocks linked after the genesis block 401 in the full-chain can be divided into an interval, i.e., three sequentially connected blocks are included in an interval; for example, the sequentially connected blocks in the full-chain are: genesis block 401→block 402→block 403→block 404→…→block 405→block 406→block 407→…, then the genesis block 401 can be set as a separate interval, and then every three blocks linked after the genesis block 401 can be divided into an interval, for example, the first interval includes block 402→block 403→block 404, and the second interval includes block 405→block 406→block 407. Of course, the number of intervals set and the number of blocks included in each interval are not limited in the embodiments of the present application, for example, the number of blocks included in each interval can be the same or different, which is specifically explained here.
[0132] Based on the above description, it can be known that, by deploying the block synchronization contract in the full-chain node, the full-chain node can call the block synchronization contract to divide the plurality of sequentially connected blocks linked after the genesis block in the full-chain into N intervals, so as to prepare for subsequent operations.
[0133] S203: calling the block synchronization contract to set the state of the i+1th interval to an exclusive state, and extracting the block header hash of each block in the i+1th interval and the block header hash of the target block in the i th interval from the full-chain.
[0134] It should be noted that the block synchronization contract deployed in the full node contains one or more methods, and different functions can be realized when different methods in the block synchronization contract are called. The block synchronization contract can include but is not limited to the following methods: a preparation method (prepare method), a withdrawal method (withDraw method), a storage proof method (saveProof method), etc. Among them, the preparation method can be used to set a certain interval in the full blockchain to an exclusive state (or called pending state); for example, when the full node wants to generate proof information for the i+1th interval of the N intervals, it can call the preparation method in the block synchronization contract to set the i+1th interval to an exclusive state, when the i+1th interval is in the exclusive state occupied by the full node, the full node has the operation permission (such as the permission to obtain the block header or the information in the block header) of the block in the i+1th interval, and other full nodes in the blockchain network do not have the operation permission of the block in the i+1th interval. The withdrawal method can be used to cancel or release the exclusive state of a certain interval, when the exclusive state of the certain interval is released, the full nodes in the blockchain network all have the operation permission of the block in the certain interval. The storage proof method can be used to store the proof information generated by the full node for a certain interval; for example, after the full node generates the proof information for the i+1th interval, the full node can call the storage proof method in the block synchronization contract to store the proof information of the i+1th interval in the full blockchain, and also store it in the storage space of the full node.
[0135] In a specific implementation, when the state of a certain interval in the full blockchain is set to an exclusive state, it indicates that the full node wants to generate proof information for the certain interval, and then the corresponding information can be extracted from the full blockchain to generate proof information for the certain interval. Taking the i+1th interval as an example, i=1, 2…N-1, N is an integer greater than 1, when it is detected that the full node sets the state of the i+1th interval in the full blockchain to an exclusive state, the block header hash of each block in the i+1th interval and the block header hash of the target block in the i th interval can be extracted from the full blockchain; wherein, the target block can refer to the block with the largest height in the corresponding interval, i.e. the last block in the corresponding interval; for example, the target block in the i th interval refers to the block with the largest height in the i th interval; for example, Figure 4 The target block in the first interval in the block 404, and the target block in the second interval refers to the block 407. It can be understood that the specific implementation of generating proof information for each interval in the full blockchain by the full node is similar; for the sake of description, the generation of proof information for the i+1th interval will be taken as an example in the following.
[0136] S204: According to the zero-knowledge proof circuit, the block header hash of each block in the i+1 interval and the block header hash of the target block in the i interval are verified, and the proof information of the i+1 interval is generated.
[0137] Based on the foregoing description, it can be known that the zero-knowledge proof circuit is generated based on the proposition to be proved, and the operation logic for verifying the blocks in the interval is written in the zero-knowledge proof circuit; therefore, after the block header hash of each block in the i+1 interval pulled from the full-chain and the block header hash of the target block in the i interval are input into the zero-knowledge proof circuit, the proof information of the i+1 interval can be directly generated based on the output information of the zero-knowledge proof circuit. The proof information of the i+1 interval can include: the output information of the zero-knowledge proof circuit corresponding to the i+1 interval, and a proof string (also known as a zk-snark proof). Wherein: ① the output information of the zero-knowledge proof circuit corresponding to the i+1 interval includes: the block header hash of the target block in the i interval calculated by the zero-knowledge proof circuit, the block header hash of each block in the i+1 interval calculated by the zero-knowledge proof circuit, and the circuit check result. Wherein, the block header hash of any block is generated based on the block header hash of the previous block of the block and the parameters contained in the block header of the block, and the parameters contained in the block header of the block can include but are not limited to: the block height of the block, the timestamp of the block, and the Merkle root of the block, etc. ② The proof string is generated based on the calculation process of the output information of the zero-knowledge proof circuit by the prover; that is, the proof string can refer to the calculation process of the zero-knowledge proof circuit by the prover, and the generation of the proof string can be used to indicate that the full-node has executed the calculation process based on the zero-knowledge proof circuit. Wherein, the proof string can be a string composed of multiple characters, and the characters can include but are not limited to: English characters (i.e. letters), numbers and punctuation marks (such as comma ", ", period ".", square brackets "[ ]", etc.).
[0138] In the embodiments of the present application, the generation process of the proof string in the proof information of the i+1 interval can refer to the related content described above, and the calculation process of the output information of the zero-knowledge proof circuit by the zero-knowledge proof circuit on the block header hash of each block in the i+1 interval and the block header hash of the target block in the i interval will be mainly given below. Figure 5 , the calculation process of the output information of the zero-knowledge proof circuit by the zero-knowledge proof circuit on the block header hash of each block in the i+1 interval and the block header hash of the target block in the i interval will be mainly given below.
[0139] s11: For each block header of each block obtained from the full-chain, calculate the block header hash of each block by using the block header hash of the previous block and the parameters required for calculating the block header hash. Each block header hash involved in this step can include: the block header hash of the target block in the i-th interval in the full-chain, and the block header hash of each block in the i+1-th interval.
[0140] As described in the foregoing, the block header hash of any block is generated according to the block header hash of the previous block of the any block and the parameters contained in the block header of the any block (i.e., the parameters required for calculating the block header hash), then the specific implementation process of generating the block header hash of each block can include: on the one hand, obtaining the block header hash of the first reference block in the i-th interval from the full-chain, the block header hash of the first reference block is stored in the block header of the first reference block, the first reference block can refer to the block with a block height of 1 less than the block height of the target block in the i-th interval, for example, if the target block is the last block in the i-th interval, then the first reference block is the block adjacent to the last block in the i-th interval. Then, according to the block header hash of the first reference block in the i-th interval, calculate the block header hash of the target block in the i-th interval. On the other hand, for each block in the i+1-th interval, calculate the block header hash of each block by using the block header hash of the previous block, to obtain the block header hash of each block in the i+1-th interval; wherein the previous block of the block with the smallest block height in the i+1-th interval (such as the first block in the i+1-th interval) is the target block in the i-th interval. Through the implementation process shown in the above two aspects, the block header hash of the target block in the i-th interval can be calculated, and the block header hash of each block in the i+1-th interval can be calculated.
[0141] s12: Verify the calculated block header hash of the target block in the i-th interval and the calculated block header hash of each block in the i+1-th interval to generate a circuit check result. In specific implementation, compare the block header hash of the target block in the i-th interval calculated by the zero-knowledge proof circuit with the block header hash of the target block in the i-th interval extracted from the full-chain. And compare the block header hash of each block in the i+1-th interval calculated by the zero-knowledge proof circuit with the block header hash of the corresponding block in the i+1-th interval extracted from the full-chain.
[0142] If the comparison result is successful, that is, the block header hash of the target block in the i-th interval calculated by the zero-knowledge proof circuit matches (or is the same as) the block header hash of the target block in the i-th interval extracted from the full blockchain (i.e., the input information of the zero-knowledge proof circuit), and the block header hash of each block in the i+1-th interval calculated by the zero-knowledge proof circuit matches the block header hash of the corresponding block in the i+1-th interval extracted from the full blockchain, the circuit check result is generated, and the value of the circuit check result is assigned to a preset value, such as true (or the number 1). When the value of the circuit check result is the preset value, the circuit check result can be used to indicate that the block header hash calculated by the zero-knowledge proof circuit matches the block header hash of the corresponding block in the full blockchain.
[0143] On the contrary, if the comparison result is a comparison failure, such as the block header hash of the target block in the i-th interval calculated by the zero-knowledge proof circuit does not match the block header hash of the target block in the i-th interval extracted from the full blockchain, and / or the block header hash of each block in the i+1-th interval calculated by the zero-knowledge proof circuit does not match the block header hash of the corresponding block in the i+1-th interval extracted from the full blockchain, the value of the generated circuit check result is assigned to a non-pre-set value, which can be any value other than the preset value, such as false (or the number 0). When the value of the circuit check result is the non-pre-set value, the circuit check result can be used to indicate that the block header hash calculated by the zero-knowledge proof circuit does not match the block header hash of the corresponding block in the full blockchain.
[0144] s13: Based on the calculated block header hash of the target block in the i-th interval, the calculated block header hash of each block in the i+1-th interval, and the circuit check result, the output information of the zero-knowledge proof circuit is composed.
[0145] By performing the implementation process shown in steps s11-s13, the output information of the zero-knowledge proof circuit can be obtained.
[0146] In addition, the embodiment of the present application also supports releasing or canceling the exclusive state of the i+1th interval after detecting that the proof information of the i+1th interval has been generated; when the i+1th interval is not in the exclusive state, all full nodes in the blockchain network can operate on the blocks in the i+1th interval, such as synchronizing blocks, obtaining block headers, and the like. Specifically, after detecting that the proof information of the i+1th interval has been generated, the full node can call the storage proof method (such as the saveProof method) in the deployed block synchronization contract to set the state of the i+1th interval from the exclusive state (pending state) to the non-exclusive state (or called saved state). In addition to the above description, in addition to the full node for making the proof information of the i+1th interval, the exclusive state of the i+1th interval is actively released after detecting that the proof information of the i+1th interval has been generated; the embodiment of the present application also supports releasing the exclusive state of the i+1th interval when the i+1th interval is in the exclusive state for a long time.
[0147] Optionally, the process of releasing the exclusive state of the i+1th interval can be performed by the full node for making the proof information of the i+1th interval; when the full node for making the proof information of the i+1th interval sets the state of the i+1th interval to the exclusive state, the time stamp when the i+1th interval enters the exclusive state is recorded, and the timer is started to start timing; if the timer of the full node records that the duration of the i+1th interval in the exclusive state is greater than the duration threshold since the i+1th interval is set to the exclusive state, the exclusive state of the i+1th interval is released. Of course, the above is an example of timing the duration of the i+1th interval in the exclusive state by the timer; in other implementation manners, the duration of the i+1th interval in the exclusive state can also be timed by the timer. In this implementation manner, when the i+1th interval is set to the exclusive state, the timer is started to time, such as setting the duration of the timer to 2 minutes, so that when the duration of the i+1th interval in the exclusive state is greater than 2 minutes, the exclusive state of the i+1th interval can be automatically released.
[0148] Optionally, the process of releasing the exclusive state of the i+1th interval can also be performed by other full nodes in the blockchain network except the full node for making the proof information of the i+1th interval; if the other full nodes in the blockchain network except the full node for making the proof information of the i+1th interval find that the duration of the i+1th interval in the exclusive state is greater than the duration threshold when querying the state of the i+1th interval, the exclusive state of the i+1th interval can be canceled by the other nodes calling the withdrawal method in the block synchronization contract.
[0149] It should be noted that the embodiment of the present application can adopt one or more of the above two optional modes in actual application to release the exclusive state of the i+1 interval; but the embodiment of the present application does not limit which mode is used to release the exclusive state of the i+1 interval.
[0150] S205: Store the proof information of the i+1 interval to the full amount blockchain.
[0151] Based on the specific implementation process shown in the foregoing step S204, after the full amount node completes the proof information of the i+1 interval, the full amount node also stores the proof information of the i+1 interval to the full amount blockchain, so as to realize the on-chain of the proof information of the i+1 interval.
[0152] As described in the foregoing, the blockchain network involved in the embodiment of the present application can include a witness subnetwork and a consensus subnetwork, so when the full amount node used to make the proof information of the i+1 interval belongs to different subnetworks, the full amount node stores the proof information of the i+1 interval to the full amount blockchain in different ways. In one implementation, when the full amount node used to make the proof information of the i+1 interval is any consensus node in the consensus subnetwork, the implementation of the any consensus node storing the proof information of the i+1 interval to the full amount blockchain can include: the any consensus node generates a new block based on the proof information of the i+1 interval, then the consensus nodes in the consensus subnetwork consensus the new block, and after the consensus succeeds, the any consensus node adds the new block to the full amount blockchain, so that the other full amount nodes in the consensus subnetwork and / or the business nodes in the witness subnetwork can synchronize to the new block from the full amount blockchain, and then synchronize to the proof information of the i+1 interval. In other implementations, when the full amount node used to make the proof information of the i+1 interval is any business node in the witness subnetwork, the implementation of the any business node storing the proof information of the i+1 interval to the full amount blockchain can include: the any business node forwards the proof information of the i+1 interval to the consensus nodes in the consensus subnetwork through the routing nodes in the witness subnetwork and the consensus subnetwork, and the consensus nodes add the proof information of the i+1 interval to the full amount blockchain after the consensus succeeds.
[0153] In the embodiment of the present application, the full-node in the blockchain network can deploy a block synchronization contract to divide the multiple blocks in the full-blockchain into N intervals, and then generate the proof information of each interval, so that the subsequent light-node can synchronize only a small number of block headers from the full-blockchain, such as the block headers of the target blocks in each interval. The verification of the proof information of the i+1 interval can realize the verification of the validity of the full-block header in the full-blockchain. The efficiency of block synchronization and verification is improved, the overhead required for block synchronization of the light-node is reduced, and the burden of the light-node is reduced.
[0154] The above Figure 2 The embodiment shown mainly illustrates the implementation process of the full-node in the blockchain network generating proof information for each interval in the full-blockchain. The following Figure 6 will query in detail the implementation process of the verifier (such as the light-node) verifying the proof information generated by the full-node. Figure 6 Fig. 1 shows a flowchart of a block synchronization method based on a blockchain network according to an example embodiment of the present application. The block synchronization scheme can be jointly executed by the full-node and the light-node in the blockchain network. The scheme can specifically include but is not limited to steps S601-S606:
[0155] S601: The light-node sends a block synchronization request to the full-node.
[0156] S602: The full-node responds to the block synchronization request sent by the light-node, and obtains the block header of the target block in the i+1 interval, the proof information of the i+1 interval, and the verifier public string from the full-blockchain.
[0157] S603: The light-node receives the block header of the target block in the i+1 interval, the proof information of the i+1 interval, and the verifier public string sent by the full-node.
[0158] In steps S601-S603, the block synchronization request is used to request the full-node in the blockchain network to return the block header of the target block in the i+1 interval, the proof information of the i+1 interval, and the verifier public string. The specific implementation process of the full-node generating the proof information of the i+1 interval and the verifier public string can be referred to the related description of the foregoing Figure 2 embodiment, which will not be repeated here. After receiving the block synchronization request sent by the light-node, the full-node responds to the block synchronization request to call the deployed block synchronization contract to obtain the proof information of the i+1 interval and the verifier public string, and returns the obtained proof information of the i+1 interval and the verifier public string, and the block header of the target block in the i+1 interval to the light-node.
[0159] It should be noted that the embodiment of the present application supports the light node to concurrently acquire the block headers of the target blocks in the M intervals from the full node, M is an integer, M∈[1, N]; at this time, the i+1 interval is any one of the M intervals, and the i interval is the interval adjacent to the i+1 interval in the M intervals. The so-called concurrent acquisition of M intervals can refer to: without acquiring the M intervals in sequence according to the connection order of each interval in the full blockchain. Referring to Figure 7a , the light node can first send a first block synchronization request to the full node, and the first block synchronization request is used to request to acquire the related information of the i+1 interval in the M intervals (such as the block header of the target block in the i+1 interval and the proof information of the i+1 interval); then, the light node sends a second block synchronization request to the full node, and the second block synchronization request is used to request to acquire the related information of the i interval in the M intervals. Referring to Figure 7b , the light node can send a block synchronization request to the full node, and the block synchronization request can be used to request to concurrently acquire the related information of at least two intervals in the M intervals, such as requesting to acquire the related information of the i interval and the related information of the i+1 interval in one block synchronization request. The embodiment of the present application does not limit the specific implementation mode of the light node to concurrently acquire the related information of the M intervals, which is described here.
[0160] Based on the above block acquisition mode of concurrent acquisition, if the light node has acquired the block header of the target block in any interval (such as the i interval) located before the i+1 interval in the full blockchain of the full node and the proof information of the interval before sending the block synchronization request to the full node for acquiring the block header of the i+1 interval and the proof information of the i+1 interval, it is determined that the verifier public string has been acquired when acquiring the corresponding information of the interval, and then the full node can no longer return the verifier public string to the light node in response to the block synchronization request when detecting that the verifier public string has been sent to the light node. Of course, the full node can also return the verifier public string every time the light node sends a block synchronization request, and the embodiment of the present application does not limit the returning mode of the verifier public string.
[0161] S604: The light node acquires the block header hash of the target block in the i interval on the full blockchain.
[0162] As described in the foregoing, the block header hash of a block is generated based on the block header hash of the previous block of the block and the parameters contained in the block header of the block, therefore, to calculate the block header hash of the first block in the i+1th interval, the embodiment of the application needs to acquire the block header hash of the target block (i.e. the last block) in the ith interval, so as to calculate the block header hash of the first block in the i+1th interval based on the block header hash of the target block in the ith interval and the parameters contained in the block header of the first block in the i+1th interval, and further to realize the verification of the proof information of the i+1th interval.
[0163] The implementation manner in which the lightweight node acquires the block header hash of the target block in the ith interval on the full-block chain can include: if the lightweight node has acquired the block header hash of the target block in the ith interval from the full-block chain before verifying the proof information of the i+1th interval, then in this case, the lightweight node can directly acquire the block header of the target block in the ith interval from the storage space in the lightweight node. Alternatively, the lightweight node can also send a request to the full-node for acquiring the block header hash of the target block in the ith interval, i.e. the lightweight node acquires the block header hash of the target block in the ith interval from the full-block chain of the full-node. The embodiment of the application does not limit which of the above manners is used to acquire the block header hash of the target block in the ith interval.
[0164] S605: The lightweight node verifies the proof information of the i+1th interval based on the block header of the target block pair in the ith interval and the block header of the target block in the i+1th interval.
[0165] Considering that any block in a legal full-block chain contains the block header hash of the previous block, therefore, the lightweight node uses a serial verification manner when verifying the proof information of the interval, i.e. the verification of the proof information of the i+1th interval is continued only when the verification of the proof information of the ith interval is successful; if the verification of the proof information of the ith interval fails, it means that one or more blocks contained in the ith interval are illegal, then it is meaningless to continue verifying the proof information of the i+1th interval, and the verification of the proof information of the interval after the ith interval is stopped.
[0166] An exemplary schematic diagram of concurrently acquiring the proof information of each interval and serially verifying the proof information of each interval can be seen from Figure 8 For example, Figure 8As shown, the process of the lightweight node serially verifying the proof information of each block can generally include: first synchronizing the block header of the genesis block on the full-block chain from the full nodes; when i = 1, verifying the proof information of the ith interval according to the block header of the genesis block and the block header of the target block in the ith interval; if the proof information of the ith interval is verified successfully, storing the block header of the target block in the ith interval to the storage space, and continuing to obtain the block header hash of the first reference block in the ith interval from the proof information of the ith interval, and continuing to verify the proof information of the (i+1)th interval; and so on, until the proof information of at least N intervals in the full-block chain is verified successfully, or until the verification result of the proof information of a certain interval is failure, the verification operation is stopped. Based on Figure 8 As can be known from the related description of the embodiment, the genesis block in the full-block chain can belong to a single interval, and the lightweight node defaults that the block header of the genesis block is legal in the process of serial verification.
[0167] Based on Figure 2 As can be known from the related description of the embodiment, the proof information of the (i+1)th interval includes: a proof string and output information of the zero-knowledge proof circuit; the proof string is generated by the full node based on the prover public string, and is generated by the full node based on the prover public string for the calculation process of the output information calculated by the zero-knowledge proof circuit; the generation of the proof string indicates that the full node has executed the calculation process based on the zero-knowledge proof circuit; the prover public string is a key used by the prover; the prover includes the full node. The output information of the zero-knowledge proof circuit includes: the block header hash of the target block in the ith interval calculated by the zero-knowledge proof circuit, the block header hash of each block in the (i+1)th interval calculated by the zero-knowledge proof circuit, and the circuit check result. The circuit check result is used to indicate whether the block header hash calculated by the zero-knowledge proof circuit matches the block header hash of the corresponding block in the full-block chain. Then in the specific implementation process, the lightweight node verifies the proof information of the (i+1)th interval based on the block header of the target block in the ith interval and the block header hash of the target block in the (i+1)th interval, which can include: verifying the proof string included in the proof information of the (i+1)th interval, and verifying the output information of the zero-knowledge proof circuit.
[0168] The specific implementation process of the lightweight node verifying the proof information of the (i+1)th interval based on the block header of the target block in the ith interval and the block header hash of the target block in the (i+1)th interval will be described below, wherein:
[0169] 1) Obtain the verifier public string from the full amount blockchain, and verify the proof string in the proof information of the i+1 interval with the verification public string to obtain a first verification result. The proof string is generated by the prover (i.e., the full amount node) using the prover string, and is calculated by the zero-knowledge proof circuit to obtain the output information of the calculation process. When the first verification result is a verification success, it can be determined that the full amount node has indeed completed the calculation process of the zero-knowledge proof circuit. The calculation process can include: the process of calculating the block header hash of the target block in the i interval using the zero-knowledge proof circuit, the process of calculating the block header hash of each block in the i+1 interval using the zero-knowledge proof circuit, and the process of generating the circuit check result.
[0170] 2) Read the value of the circuit check result from the output information of the zero-knowledge proof circuit contained in the proof information of the i+1 interval. As described above, the circuit check result output by the zero-knowledge proof circuit can be used to indicate whether the block header hash calculated by the zero-knowledge proof circuit matches the block header hash of the corresponding block in the full amount blockchain. If the value of the circuit check result is a preset value, the circuit check result at this time indicates that the block header hash calculated by the zero-knowledge proof circuit matches the block header hash of the corresponding block in the full amount blockchain, indicating that the full amount node judges that the block in the full amount blockchain is legal. On the contrary, if the value of the circuit check result is a non-pre-set value, the circuit check result at this time indicates that the block header hash calculated by the zero-knowledge proof circuit does not match the block header hash of the corresponding block in the full amount blockchain, indicating that the full amount node judges that there is an illegal block in the full amount blockchain.
[0171] 3) Verify the block header hash contained in the output information of the zero-knowledge proof circuit in the proof information of the i+1 interval according to the block header of the target block in the i interval to obtain a second verification result. In a specific implementation, the second verification result includes a first comparison result and a second comparison result; wherein the first comparison result is obtained by verifying the block header of the target block in the i interval, and the second comparison result is obtained by verifying the block header of the target block in the i+1 interval. The specific implementation process of obtaining the first comparison result and the second comparison result is given below.
[0172] ①Verify the block header of the target block in the ith interval to obtain a first comparison result. Specifically, since the lightweight node verifies the proof information of each interval in a serial verification manner, when the lightweight node triggers verification of the proof information of the (i+1)th interval, it can be determined that the proof information of the ith interval has been successfully verified, and the lightweight node can obtain the block header hash of the first reference block in the ith interval from the proof information of the ith interval. The first reference block refers to a block in the ith interval whose block height is one less than that of the target block in the ith interval. Then, according to the block header hash of the first reference block and the parameters (such as the timestamp, block height, etc.) contained in the block header of the target block in the ith interval, the block header hash of the target block in the ith interval is calculated. Finally, the block header hash of the target block in the ith interval calculated according to the block header hash of the first reference block is compared with the block header hash of the target block in the ith interval contained in the output information of the zero-knowledge proof circuit in the proof information of the ith interval to obtain a first comparison result. When the first comparison result is a comparison success, it indicates that the block header of the target block in the ith interval is legal, and the verification of the block header of the target block in the (i+1)th interval continues. Conversely, when the first comparison result is a comparison failure, it indicates that the block header of the target block in the ith interval is illegal, and the subsequent verification operation is stopped.
[0173] ②Verify the block header of the target block in the (i+1)th interval to obtain a second comparison result. On the premise that the block header of the target block in the ith interval is a legal block header, the block header hash of the second reference block in the (i+1)th interval can be obtained from the proof information of the (i+1)th interval; the second reference block refers to a block in the (i+1)th interval whose block height is one less than that of the target block in the (i+1)th interval. Then, according to the block header hash of the second reference block and the block header hash of the target block in the (i+1)th interval, the block header hash of the target block in the (i+1)th interval is calculated. Finally, the block header hash of the target block in the (i+1)th interval calculated according to the block header hash of the second reference block is compared with the block header hash of the target block in the (i+1)th interval contained in the output information of the zero-knowledge proof circuit in the proof information of the (i+1)th interval to obtain a second comparison result. When the second comparison result is a comparison success, it indicates that the block header of the target block in the (i+1)th interval is legal, and the verification of the proof information of the (i+2)th interval continues. Conversely, when the second comparison result is a comparison failure, it indicates that the block header of the target block in the (i+1)th interval is illegal, and the subsequent verification operation is stopped.
[0174] Based on the first comparison result and the second comparison result, a second verification result is generated. If the first comparison result is a comparison success and the second comparison result is a comparison success, it is determined that the second verification result is a verification success. If there is any one of the first comparison result and the second comparison result being a comparison failure, it is determined that the second verification result is a verification failure. When the second verification result is a verification success, it indicates that the block header hash of the target block in the ith interval calculated matches the block header hash of the target block in the ith interval contained in the output information of the zero-knowledge proof circuit, and the block header hash of the target block in the i+1th interval calculated matches the block header hash of the target block in the i+1th interval contained in the output information of the zero-knowledge proof circuit. In this case, it is determined that all the block headers of the blocks linked after the target block in the ith interval and before the target block in the i+1th interval are legal, and the verification of the proof information of the i+2th interval is continued. Conversely, when the second verification result is a verification failure, it indicates that the block header hash of the target block in the ith interval calculated does not match the block header hash of the target block in the ith interval contained in the output information of the zero-knowledge proof circuit, and / or the block header hash of the target block in the i+1th interval calculated does not match the block header hash of the target block in the i+1th interval contained in the output information of the zero-knowledge proof circuit. In this case, it is determined that one or more block headers of all the blocks linked after the target block in the ith interval and before the target block in the i+1th interval are illegal, and the verification of the proof information of the subsequent interval is stopped.
[0175] S606: If the proof information of the i+1th interval is verified successfully, the block header of the target block in the i+1th interval is stored in a storage space.
[0176] In a specific implementation, when it is determined that the proof information of the i+1th interval is verified successfully, the embodiment of the present application supports storing the block header of the target block in the ith interval into a storage space. The storage space can refer to a space for storing the block headers of the target blocks in the intervals that have been verified successfully. The target blocks in the intervals that have been verified successfully in the storage space can be stored according to a storage rule. The storage rule can include but is not limited to sequential storage, random storage, etc. Sequential storage refers to storing the block headers of the target blocks in the intervals that have been verified successfully according to the connection order between the intervals. An exemplary schematic diagram of sequentially storing the block headers of the blocks can be seen from FIG. 2. Figure 9 Random storage refers to randomly storing the block headers of the target blocks in the intervals that have been verified successfully into the space without caring about the storage order of the block headers.
[0177] In the embodiments of the present application, the light node in the blockchain network can synchronize only the block headers of a small number of blocks from the full blockchain of the full node, such as the block header of the genesis block and the block header of the target block in each interval, so as to verify the validity of the full block header in the full blockchain according to the block headers of a small number of blocks, improve the efficiency of block synchronization and verification, enable instant query of the existence of a transaction even in the case of not synchronizing the transaction block, and reduce the overhead required for block synchronization and the burden on the light node.
[0178] The above Figure 2 The embodiments shown mainly illustrate the implementation process of generating proof information for each interval in the full blockchain by the full node in the blockchain network, Figure 6 The embodiments shown mainly illustrate the implementation process of verifying the proof information generated by the full node by the verifier (such as a light node). The implementation process of the verifier to perform a business function (such as a business function to query the existence of a transaction) is described below. Figure 10 The implementation process of the verifier to perform a business function (such as a business function to query the existence of a transaction) is described below. Figure 10 FIG. 1 shows a flowchart of a block synchronization method based on a blockchain network according to an example embodiment of the present application. The block synchronization scheme can be executed by the full node and the light node in the blockchain network. The scheme can specifically include but is not limited to steps S1001-S1011.
[0179] S1001: The full node generates proof information for each interval in the full blockchain network and stores the proof information of each interval.
[0180] It should be noted that the specific implementation process of the full node to generate proof information for each interval in the full blockchain can refer to the related description of the specific implementation process shown in steps S201-S205 of the embodiments shown in the foregoing description, and will not be described here. Figure 2 The specific implementation process shown in steps S201-S205 of the embodiments shown in the foregoing description, and will not be described here.
[0181] S1002: The full node receives a block synchronization request sent by the light node.
[0182] S1003: The full node acquires the block header of the target block in the i+1th interval, the proof information of the i+1th interval, and the verifier public string in response to the block synchronization request.
[0183] S1004: The full node returns the block header of the target block in the i+1th interval, the proof information of the i+1th interval, and the verifier public string to the light node.
[0184] S1005: The lightweight node verifies the proof information of the i+1th interval based on the block header of the target block in the i+1th interval received, the proof information of the i+1th interval, and the verifier public string, and stores the block header of the target block in the i+1th interval after successful verification.
[0185] It should be noted that the specific implementation process shown in steps S1002-S1005 can refer to the foregoing Figure 6 related description of the specific implementation process shown in steps S601-S606 in the foregoing embodiment, which is not repeated here. In addition, the process shown in steps S1002-S1005 is introduced by taking the verification of the proof information of the i+1th interval by the lightweight node as an example; in actual application, the lightweight node verifies the proof information of each interval in sequence in a serial verification manner; the specific implementation process of the lightweight node verifying the proof information of each interval can refer to the related description in the foregoing Figure 6 embodiment.
[0186] S1006: The lightweight node receives the transaction query information sent by the client.
[0187] S1007: The lightweight node generates a transaction query request based on the transaction query information and sends the transaction query request to the full-node.
[0188] In steps S1006-S1007, as described in the foregoing, the lightweight node in the blockchain network can undertake some business functions; for example, in the invoice transaction chaining business scenario, the lightweight node can undertake the business function of querying the existence of a transaction, such as querying whether a target transaction exists in the full-blockchain. In specific implementation, the client that has a query demand for the existence of a target transaction can send transaction query information to the lightweight node, the transaction query information including the transaction hash of the target transaction, the Merkle path of the target transaction, and the block height of the block to which the target transaction belongs; when the lightweight node receives the transaction query information sent by the client, it determines to generate a transaction query event for the target transaction, that is, the transaction query event is an event generated by the lightweight node when it obtains the transaction query information sent by the client, and the lightweight node can send a transaction query request to the full-node in response to the transaction query event for the target transaction.
[0189] S1008: The full-node receives the transaction query request sent by the lightweight node and obtains the block header of the block to which the target transaction belongs in response to the transaction query request.
[0190] S1009: The full-node returns the block header of the block to which the target transaction belongs and the proof information of the i+1th block corresponding to the block to which the target transaction belongs to the lightweight node.
[0191] In steps S1008-S1009, the transaction query request sent by the lightweight node contains the block height corresponding to the target transaction, so that after the full node receives the transaction query request, it can determine the block to which the target transaction belongs based on the block height corresponding to the target transaction. For example, if the block height corresponding to the target transaction carried in the transaction query request is 7, the sixth block linked to the genesis block in the full blockchain is determined as the block to which the target transaction belongs. Furthermore, after determining the block to which the target transaction belongs, the full node can call the block synchronization contract to obtain the proof information of the i+1th interval corresponding to the block to which the target transaction belongs. Then, the proof information of the i+1th interval corresponding to the block to which the target transaction belongs and the block header of the block to which the target transaction belongs are returned to the lightweight node.
[0192] S1010: The lightweight node queries whether the block to which the target transaction belongs contains the target transaction based on the block header of the block to which the target transaction belongs and the proof information of the i+1th block corresponding to the block to which the target transaction belongs, and obtains the query result.
[0193] S1011: The lightweight node outputs the query results.
[0194] In steps S1010-S1011, it is worth noting that Figure 6 In the illustrated embodiment, the lightweight node has successfully verified the proof information of the i+1th interval, that is, before querying whether there is a block in the i+1th interval containing the target transaction, the lightweight node has successfully verified that: the block header of the target block in the i+1th interval and the block headers of all blocks in the i+1th interval in the full blockchain are legal (or called valid blocks); then, in this transaction query verification, the lightweight node only needs to confirm that the block to which the target transaction belongs is any valid block in the i+1th block, and that the target transaction is contained in the block to which the target transaction belongs.
[0195] Based on the above description, the implementation process of the lightweight node querying whether the target transaction exists in the block to which the target transaction belongs is briefly introduced as follows. Specifically, the lightweight node obtains the block header of a third reference block from the output information of the zero-knowledge proof circuit in the proof information of the i+1th interval, where the third reference block refers to a block in the i+1th interval whose block height is 1 less than the block height of the block to which the target transaction belongs. Then, the block header hash of the block to which the target transaction belongs is calculated according to the block header hash of the third reference block and the parameters contained in the block header of the block to which the target transaction belongs. Next, if the calculated block header hash of the block to which the target transaction belongs is the same as the block header hash of the block to which the target transaction belongs in the output information of the zero-knowledge proof circuit in the proof information of the i+1th interval, it indicates that the block to which the target transaction belongs is one of the valid blocks in the i+1th interval, and then a Merkle root is generated based on the transaction hash of the target transaction and the Merkle path of the target transaction. Then, if it is detected that the generated Merkle root exists in the block header of the block to which the target transaction belongs, it indicates that the target transaction exists in the block to which the target transaction belongs, and then a query result is generated, where the query result is used to indicate that the target transaction exists in the block to which the target transaction belongs. Finally, the lightweight node can return the query result to the client when the query result is calculated.
[0196] It should be noted that the above is an introduction to the business logic of querying the existence of a transaction, taking the client and the lightweight node as different devices as an example. However, in actual applications, the client and the lightweight node can be the same device, such as the lightweight node being a client connected to the blockchain network, and the embodiments of the present application do not limit whether the client and the lightweight node are the same device. In addition, when the embodiments of the present application are applied to specific products or technologies, such as when the lightweight node synchronizes the target block containing the target transaction from the full node, permission or consent of the target object generating the target transaction is required; and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of relevant countries and regions, such as the acquisition and chaining of the target transaction need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0197] The block synchronization method based on the block chain network provided by the embodiments of the present application has obvious advantages compared with the existing mainstream block synchronization method. The advantages of the block synchronization method provided by the present application are given below according to the comparison with the existing mainstream block synchronization method. In the existing mainstream block synchronization method, a business node newly added to the block chain network needs to start from the genesis block of the full block chain and synchronously synchronize the block headers of each block in sequence, so as to confirm that the block header of the synchronized block is valid. This way of synchronously synchronizing the block headers of all blocks reduces the block synchronization efficiency, has a large block synchronization overhead, and is not conducive to the business node to perform the business function of querying the existence of a transaction. For example, before the block height synchronized on the business node catches up with the full block chain, if the block height of the full block chain is H and the business node synchronizes to the block with a height of h, the business node receives a query request and needs to query whether a transaction in the block with a height of h+n is on the chain. In this case, since the business node has not synchronized to the block with a height of h+n, the business node cannot find the transaction. However, the light node in the block chain network provided by the embodiments of the present application can synchronize only the block headers of a small number of blocks from the full block chain of the full node, such as the block header of the genesis block and the block header of the target block in each interval. The validity of the full block header in the full block chain can be verified according to the small number of block headers, the efficiency of block synchronization and verification is improved, the existence of a transaction can be queried in real time even in the case of not synchronizing the transaction block, the overhead required for block synchronization is reduced, and the burden of the light node is reduced.
[0198] The above describes the method of the embodiments of the present application in detail. In order to better implement the above method of the embodiments of the present application, the device of the embodiments of the present application is provided accordingly.
[0199] Figure 11 A structure diagram of a block synchronization device based on a block chain network is shown, which can be a computer program (including program code) running in a light node. The block synchronization device based on the block chain network can be used to execute part or all of the steps in the method embodiments shown in Figure 6 and Figure 10 The block chain network includes full nodes and light nodes. The full nodes store a full block chain, and the full block chain includes N intervals, where N is an integer greater than 1. Each interval includes one or more sequentially connected blocks, and each interval corresponds to a proof information, which is used to prove the correctness of the blocks in the corresponding interval. The light nodes store the block headers of part of the blocks in the full block chain. The block synchronization device is a light node, and the device includes the following units:
[0200] The acquisition unit 1101 is configured to acquire a block header of a target block in an i th interval on the full-chain blockchain, and proof information of the i th interval has been successfully verified; i = 1, 2, …, N-1.
[0201] The processing unit 1102 is configured to synchronize the block header of the target block in an (i+1) th interval on the full-chain blockchain from the full-chain node, and synchronize the proof information of the (i+1) th interval.
[0202] The processing unit 1102 is further configured to verify the proof information of the (i+1) th interval based on the block header of the target block in the i th interval and the block header of the target block in the (i+1) th interval.
[0203] The processing unit 1102 is further configured to, if the proof information of the (i+1) th interval is successfully verified, store the block header of the target block in the (i+1) th interval to the storage space.
[0204] In an implementation manner, the full-chain blockchain further includes a genesis block; and the processing unit 1102 is further configured to:
[0205] synchronize the block header of the genesis block on the full-chain blockchain from the full-chain node;
[0206] when i = 1, verify the proof information of the i th interval based on the block header of the genesis block and the block header of the target block in the i th interval;
[0207] if the proof information of the i th interval is successfully verified, store the block header of the target block in the i th interval to the storage space.
[0208] In an implementation manner, the acquisition unit 1101 is configured to, when acquiring the block header of the target block in the i th interval on the full-chain blockchain, specifically configured to:
[0209] concurrently acquire the block header of the target block in M intervals from the full-chain node, M is an integer, M ∈ [1, N], and the i th interval is any one of the M intervals; or
[0210] acquire the block header of the target block in the i th interval from the storage space in the light node.
[0211] In an implementation manner, the proof information includes a proof string and output information of a zero-knowledge proof circuit; the proof string is generated by a full-chain node based on a prover public string, and is calculated by the full-chain node based on the proof string to generate a calculation process of the output information; the generation of the proof string indicates that the full-chain node has executed the calculation process based on the zero-knowledge proof circuit; the prover public string is a key used by a prover; and the prover includes the full-chain node.
[0212] The output information of the zero-knowledge proof circuit includes: a block header hash of the target block in the i th interval calculated by the zero-knowledge proof circuit, a block header hash of each block in the i+1 th interval calculated by the zero-knowledge proof circuit, and a circuit check result.
[0213] The circuit check result is used to indicate whether the block header hash calculated by the zero-knowledge proof circuit matches the block header hash of the corresponding block in the full-chain.
[0214] In an implementation manner, the full-chain stores a verifier public string; the verifier public string is a key used by the verifier; the verifier includes a light node; the processing unit 1102 is configured to, when verifying the proof information of the i+1 th interval based on the block header of the target block in the i th interval and the block header of the target block in the i+1 th interval, specifically configured to:
[0215] obtain the verifier public string from the full-chain, and verify a proof string in the proof information of the i+1 th interval by using the verifier public string to obtain a first verification result;
[0216] read a value of the circuit check result from output information of the zero-knowledge proof circuit included in the proof information of the i+1 th interval; and,
[0217] verify the block header hash included in the output information of the zero-knowledge proof circuit in the proof information of the i+1 th interval based on the block header of the target block in the i th interval to obtain a second verification result;
[0218] if the first verification result is a verification success, the value of the circuit check result is a preset value, and the second verification result is a verification success, it is determined that the verification result corresponding to the i+1 th interval is a verification success;
[0219] When the value of the circuit check result is the preset value, the circuit check result is used to indicate that the block header hash calculated by the zero-knowledge proof circuit matches the block header hash of the corresponding block in the full-chain.
[0220] In an implementation manner, when the processing unit 1102 verifies the block header hash included in the output information of the zero-knowledge proof circuit in the proof information of the i+1 th interval based on the block header of the target block in the i th interval to obtain the second verification result, the processing unit 1102 is specifically configured to:
[0221] obtain a block header hash of a first reference block in the i th interval from the proof information of the i th interval; the first reference block refers to a block with a block height smaller than that of the target block in the i th interval by 1 in the i th interval;
[0222] According to the block header hash of the first reference block, the block header hash of the target block in the i th interval is calculated;
[0223] The calculated block header hash of the target block in the i th interval is compared with the block header hash of the target block in the i th interval contained in the output information of the zero-knowledge proof circuit in the proof information of the i th interval, to obtain a first comparison result;
[0224] The block header hash of the second reference block in the i+1 th interval is obtained from the proof information of the i+1 th interval; the second reference block refers to a block in the i+1 th interval whose block height is 1 less than the block height of the target block in the i+1 th interval;
[0225] According to the block header hash of the second reference block, the block header hash of the target block in the i+1 th interval is calculated;
[0226] The calculated block header hash of the target block in the i+1 th interval is compared with the block header hash of the target block in the i th interval contained in the output information of the zero-knowledge proof circuit in the proof information of the i+1 th interval, to obtain a second comparison result;
[0227] If the first comparison result is a comparison success, and the second comparison result is a comparison success, it is determined that the second verification result is a verification success.
[0228] In an implementation manner, the processing unit 1102 is further configured to:
[0229] In response to a transaction query event for the target transaction, a transaction query request is sent to the full-node, the transaction query request containing the block height corresponding to the target transaction, so that the full-node determines the block to which the target transaction belongs based on the block height corresponding to the target transaction;
[0230] The block header of the block to which the target transaction belongs and the proof information of the i+1 th interval corresponding to the block to which the target transaction belongs returned by the full-node in response to the transaction query request are received;
[0231] Based on the block header of the block to which the target transaction belongs and the proof information of the i+1 th interval, it is queried whether the target transaction exists in the block to which the target transaction belongs, to obtain a query result;
[0232] The query result is output.
[0233] In an implementation manner, the transaction query event is an event generated when the transaction query information sent by the client is acquired; the transaction query information includes a transaction hash of a target transaction and a Merkle path of the target transaction; the processing unit 1102 is configured to query whether the target transaction exists in a block to which the target transaction belongs based on a block header of the block and proof information of an i+1th interval, and obtain a query result, and specifically configured to:
[0234] acquire a block header hash of a third reference block from output information of the zero-knowledge proof circuit in the proof information of the i+1th interval, and calculate the block header hash of the block to which the target transaction belongs according to the block header hash of the third reference block; the third reference block refers to a block with a block height smaller than that of the block to which the target transaction belongs by 1 in the i+1th interval;
[0235] if the calculated block header hash of the block to which the target transaction belongs is the same as the block header hash of the block to which the target transaction belongs in the output information of the zero-knowledge proof circuit in the proof information of the i+1th interval, a Merkle root is generated based on the transaction hash of the target transaction and the Merkle path of the target transaction;
[0236] if the generated Merkle root exists in the block header of the block to which the target transaction belongs, a query result is generated, and the query result is used to indicate that the target transaction exists in the block to which the target transaction belongs.
[0237] In an implementation manner, the target block refers to a block with the largest block height in the interval.
[0238] According to an embodiment of the present application, Figure 11 The units in the block synchronization device based on the block chain network shown can be combined into one or several other units respectively or all to constitute, or some of the units can be further split into a plurality of units with smaller functions to constitute, which can realize the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above units are divided based on logical functions, and in actual application, the functions of one unit can also be realized by multiple units, or the functions of multiple units are realized by one unit. In other embodiments of the present application, the block synchronization device based on the block chain network can also include other units, and in actual application, these functions can also be realized by other units and can be realized by multiple units. According to another embodiment of the present application, the computer program (including program codes) of the steps involved in the corresponding method shown can be constructed as Figure 6 and Figure 10 a computer program (including program codes) of the steps involved in the corresponding method shown can be constructed asFigure 11 The blockchain network-based block synchronization device shown in the above embodiments, and the blockchain network-based block synchronization method for implementing the embodiments of the present application. The computer program can be recorded on, for example, a computer-readable recording medium, and loaded into the above-mentioned computing device through the computer-readable recording medium, and run therein.
[0239] In the embodiments of the present application, the blockchain network includes full nodes and light nodes; the full nodes store a full blockchain (e.g., a blockchain containing block headers of all blocks), and the sequentially connected blocks in the full blockchain are divided into N intervals, where N is an integer greater than 1. The processing unit 1102 can only synchronize the block header of the target block in the i+1th interval on the full blockchain and the corresponding proof information from the full nodes; then, the light node verifies the proof information of the i+1th interval based on the block header of the target block in the i th interval and the block header of the target block in the i+1th interval; when the proof information of the i+1th interval is verified successfully, it can be determined that each block in the i+1th interval is valid or legal. In the above scheme, only a small number of block headers can be synchronized from the full blockchain of the full node, such as the block header of the genesis block and the block header of the target block in each interval, which can verify the validity of the full block header in the full blockchain based on a small number of block headers, improve the efficiency of block synchronization and verification, reduce the overhead required for block synchronization of the light node, and reduce the burden of the light node.
[0240] Figure 12 A structural schematic diagram of a blockchain network-based block synchronization device provided by an exemplary embodiment of the present application is shown, which can be a computer program (including program code) running in a full node; the blockchain network-based block synchronization device can be used to execute part or all of the steps in the method embodiments shown in Figure 2 and Figure 10 The blockchain network includes full nodes and light nodes; the full nodes store a full blockchain, and the full blockchain includes N intervals, where N is an integer greater than 1, each interval contains one or more sequentially connected blocks, and each interval corresponds to a proof information, which is used to prove the correctness of the blocks in the corresponding interval; the light nodes store the block headers of part of the blocks in the full blockchain; the block synchronization device is a full node, and the device includes the following units:
[0241] The receiving unit 1201 is configured to receive a block synchronization request sent by a light node;
[0242] The processing unit 1202 is configured to return, in response to the block synchronization request, the block header of the target block in the i+1th interval on the full-chain and the proof information of the i+1th interval to the light node, so that the light node verifies the proof information of the i+1th interval based on the block header of the target block in the i th interval and the block header of the target block in the i+1th interval; and after the proof information of the i+1th interval is verified successfully, the light node stores the block header of the target block in the i+1th interval into the storage space of the light node; i=1, 2, …, N-1.
[0243] In an implementation manner, the processing unit 1202 is further configured to:
[0244] obtain a zero-knowledge proof circuit generated based on a proposition to be proved, the proposition to be proved being used to indicate verification of the correctness of the block header of the part of the blocks in the full-chain;
[0245] deploy a block synchronization contract, and in the process of deploying the block synchronization contract, divide a plurality of sequentially connected blocks in the full-chain into N intervals;
[0246] invoke the block synchronization contract to set the state of the i+1th interval to an exclusive state, and extract the block header hash of each block in the i+1th interval and the block header hash of the target block in the i th interval from the full-chain; the target block in the i th interval refers to the block with the maximum block height in the i th interval;
[0247] verify the block header hash of each block in the i+1th interval and the block header hash of the target block in the i th interval according to the zero-knowledge proof circuit to generate the proof information of the i+1th interval;
[0248] store the proof information of the i+1th interval into the full-chain.
[0249] In an implementation manner, the proof information of the i+1th interval includes output information of the zero-knowledge proof circuit; and the processing unit 1202 is configured to, when verifying the block header hash of each block in the i+1th interval and the block header hash of the target block in the i th interval according to the zero-knowledge proof circuit to generate the proof information of the i+1th interval, specifically:
[0250] obtain the block header hash of a first reference block in the i th interval from the full-chain, and calculate the block header hash of the target block in the i th interval according to the block header hash of the first reference block; the first reference block refers to a block with a block height smaller than that of the target block in the i th interval by 1 in the i th interval;
[0251] For each block in the i+1th interval, the block header hash of each block is calculated by using the block header hash of the previous block, and the block header hash of each block in the i+1th interval is obtained;
[0252] The calculated block header hash of the target block in the i th interval and the calculated block header hash of each block in the i+1th interval are verified to generate a circuit check result;
[0253] The output information of the zero-knowledge proof circuit includes: the block header hash of the target block in the i th interval calculated by the zero-knowledge proof circuit, the block header hash of each block in the i+1th interval calculated by the zero-knowledge proof circuit, and the circuit check result.
[0254] In an implementation manner, when the processing unit 1202 is used for verifying the calculated block header hash of the target block in the i th interval and the calculated block header hash of each block in the i+1th interval to generate a circuit check result, the processing unit 1202 is specifically used for:
[0255] Comparing the calculated block header hash of the target block in the i th interval by the zero-knowledge proof circuit with the block header hash of the target block in the i th interval extracted from the full-block chain;
[0256] And comparing the calculated block header hash of each block in the i+1th interval by the zero-knowledge proof circuit with the block header hash of the corresponding block in the i+1th interval extracted from the full-block chain;
[0257] If the comparison results are all successful, the circuit check result is generated, and the value of the circuit check result is a preset value, which is used to indicate that the block header hash calculated by the zero-knowledge proof circuit matches the block header hash of the corresponding block in the full-block chain.
[0258] In an implementation manner, the proof information corresponding to the i+1th interval further includes a proof string; and the processing unit 1202 is further used for:
[0259] Obtaining a key generation algorithm, and generating a prover public string and a verifier public string according to the key generation algorithm; the prover public string is a key used by the prover, and the prover includes a full-node; the verifier public string is a key used by the verifier, and the verifier includes a light node;
[0260] Storing the verifier public string to the full-block chain; and
[0261] The proof string is generated based on the prover public string and the output information calculated by the zero-knowledge proof circuit.
[0262] In an implementation manner, the processing unit 1202 is further configured to:
[0263] If it is detected that the proof information of the i+1th interval has been generated, the exclusive state of the i+1th interval is released; or
[0264] If the duration of the i+1th interval in the exclusive state is greater than the duration threshold since the i+1th interval is set to the exclusive state, the exclusive state of the i+1th interval is released.
[0265] According to an embodiment of the present application, Figure 11 The units in the block synchronization device based on the blockchain network shown in the embodiments of the present application can be combined into one or more other units, or some of the units can be further split into a plurality of units to constitute, which can achieve the same operation without affecting the implementation of the technical effects of the embodiments of the present application. The above units are divided based on logical functions. In actual application, the function of one unit can also be implemented by multiple units, or the functions of multiple units are implemented by one unit. In other embodiments of the present application, the block synchronization device based on the blockchain network can also include other units. In actual application, these functions can also be assisted by other units, and can be implemented by multiple units. According to another embodiment of the present application, the block synchronization device based on the blockchain network shown in the embodiments of the present application can be constructed by running the computer program (including program codes) related to the steps of the corresponding method shown in the embodiments of the present application on a general-purpose computing device such as a computer, which includes processing elements and storage elements such as a central processing unit (CPU), a random access memory (RAM), a read-only memory (ROM), and the like. Figure 2 and Figure 10 The computer program (including program codes) related to the steps of the corresponding method shown in the embodiments of the present application can be used to construct the block synchronization device based on the blockchain network shown in the embodiments of the present application, and to implement the block synchronization method based on the blockchain network in the embodiments of the present application. The computer program can be recorded on a computer readable recording medium, loaded into the above-mentioned computing device through the computer readable recording medium, and run in the computing device. Figure 12
[0266] In the embodiments of the present application, the processing unit 1202 can deploy a block synchronization contract, divide the plurality of blocks in the full-block chain into N intervals, generate the proof information of each interval, so that the subsequent light nodes can synchronize only a small number of block headers from the full-block chain, such as the block headers of the target blocks in each interval, and the verification of the proof information of the i+1 interval can realize the verification of the validity of the full-block header in the full-block chain; improve the efficiency of block synchronization and verification, reduce the overhead required for light node block synchronization, and reduce the burden of light nodes.
[0267] Figure 13 A structural diagram of a blockchain node device provided by an example embodiment of the present application is shown. Please refer to Figure 13 The blockchain node device includes a processor 1301, a communication interface 1302, and a computer readable storage medium 1303. The processor 1301, the communication interface 1302, and the computer readable storage medium 1303 can be connected by a bus or other means. The communication interface 1302 is used to receive and send data. The computer readable storage medium 1303 can be stored in the memory of the blockchain node device, and the computer readable storage medium 1303 is used to store a computer program, the computer program includes program instructions, and the processor 1301 is used to execute the program instructions stored in the computer readable storage medium 1303. The processor 1301 (or CPU (Central Processing Unit, Central Processor)) is the computing core and control core of the blockchain node device, which is suitable for implementing one or more instructions, and is particularly suitable for loading and executing one or more instructions to implement a corresponding method flow or a corresponding function.
[0268] The embodiments of the present application also provide a computer readable storage medium (Memory), which is a memory device in the blockchain node device, used to store programs and data. It can be understood that the computer readable storage medium here can include the built-in storage medium in the blockchain node device, and of course can also include the expansion storage medium supported by the blockchain node device. The computer readable storage medium provides a storage space, which stores the processing system of the blockchain node device. In the storage space, there are also one or more instructions suitable for being loaded and executed by the processor 1301, which can be one or more computer programs (including program codes). It should be noted that the computer readable storage medium here can be a high-speed RAM memory, or a non-volatile memory, such as at least one disk memory; optionally, it can also be at least one computer readable storage medium located away from the aforementioned processor.
[0269] In an embodiment, the computer readable storage medium stores one or more instructions; the one or more instructions stored in the computer readable storage medium are loaded and executed by the processor 1301 to implement the corresponding steps in the above-mentioned blockchain network-based block synchronization method embodiments. In a specific implementation, the blockchain network includes full nodes and light nodes; the full nodes store a full blockchain, the full blockchain includes N intervals, N is an integer greater than 1, each interval includes one or more sequentially connected blocks, and each interval corresponds to a proof information respectively, the proof information is used to prove the correctness of the blocks in the corresponding interval; the light nodes store the block headers of part of the blocks in the full blockchain; the blockchain node device is a light node, and the one or more instructions in the computer readable storage medium are loaded and executed by the processor 1301 to implement the following steps:
[0270] obtain the block header of the target block in the i-th interval on the full blockchain, the proof information of the i-th interval has been successfully verified; i = 1, 2…N-1;
[0271] synchronize the block header of the target block in the i+1-th interval on the full blockchain from the full node, and synchronize the proof information of the i+1-th interval;
[0272] verify the proof information of the i+1-th interval based on the block header of the target block in the i-th interval and the block header of the target block in the i+1-th interval;
[0273] if the proof information of the i+1-th interval is successfully verified, store the block header of the target block in the i+1-th interval to the storage space.
[0274] In an implementation, the full blockchain further includes a genesis block; the one or more instructions in the computer readable storage medium are loaded and executed by the processor 1301 to implement the following steps:
[0275] synchronize the block header of the genesis block on the full blockchain from the full node;
[0276] when i = 1, verify the proof information of the i-th interval based on the block header of the genesis block and the block header of the target block in the i-th interval;
[0277] if the proof information of the i-th interval is successfully verified, store the block header of the target block in the i-th interval to the storage space.
[0278] In an implementation, the one or more instructions in the computer readable storage medium are loaded by the processor 1301 and, when obtaining the block header of the target block in the i-th interval on the full blockchain, are specifically executed as follows:
[0279] obtaining the block header of the target block in the i-th interval from the storage space in the light-weight node.
[0280] obtaining the block header of the target block in the i-th interval from the storage space in the light-weight node.
[0281] In an implementation manner, the proof information includes a proof string and output information of the zero-knowledge proof circuit; the proof string is generated by the full-node based on a prover public string for a calculation process of the output information calculated by the zero-knowledge proof circuit; the generation of the proof string indicates that the full-node has executed the calculation process based on the zero-knowledge proof circuit; the prover public string is a key used by the prover; and the prover includes the full-node.
[0282] The output information of the zero-knowledge proof circuit includes: a block header hash of the target block in the i-th interval calculated by the zero-knowledge proof circuit, a block header hash of each block in the (i+1)-th interval calculated by the zero-knowledge proof circuit, and a circuit check result.
[0283] The circuit check result is used to indicate whether the block header hash calculated by the zero-knowledge proof circuit matches the block header hash of the corresponding block in the full-block chain.
[0284] In an implementation manner, the full-block chain stores a verifier public string; the verifier public string is a key used by the verifier; the verifier includes the light-weight node; and when the one or more instructions in the computer readable storage medium are loaded by the processor 1301 and executed to verify the proof information of the (i+1)-th interval based on the block header of the target block in the i-th interval and the block header of the target block in the (i+1)-th interval, the following steps are specifically executed:
[0285] obtaining the verifier public string from the full-block chain, and verifying the proof string in the proof information of the (i+1)-th interval by using the verifier public string to obtain a first verification result;
[0286] reading a value of the circuit check result from the output information of the zero-knowledge proof circuit included in the proof information of the (i+1)-th interval; and
[0287] verifying the block header hash included in the output information of the zero-knowledge proof circuit in the proof information of the (i+1)-th interval based on the block header of the target block in the i-th interval to obtain a second verification result;
[0288] if the first verification result is verification success, the value of the circuit check result is a preset value, and the second verification result is verification success, it is determined that the verification result corresponding to the (i+1)-th interval is verification success;
[0289] When the value of the circuit checking result is the preset value, the circuit checking result is used to indicate that the block header hash calculated by the zero-knowledge proof circuit matches the block header hash of the corresponding block in the full-amount blockchain.
[0290] In an implementation manner, the one or more instructions in the computer readable storage medium are loaded by the processor 1301 and executed to perform the following steps when verifying the block header hash contained in the output information of the zero-knowledge proof circuit in the proof information of the i+1 interval according to the block header of the target block in the i interval, and obtaining a second verification result:
[0291] Obtaining the block header hash of the first reference block in the i interval from the proof information of the i interval; the first reference block refers to a block in the i interval whose block height is 1 less than that of the target block in the i interval;
[0292] Calculating the block header hash of the target block in the i interval according to the block header hash of the first reference block;
[0293] Comparing the calculated block header hash of the target block in the i interval with the block header hash of the target block in the i interval contained in the output information of the zero-knowledge proof circuit in the proof information of the i interval, to obtain a first comparison result;
[0294] Obtaining the block header hash of the second reference block in the i+1 interval from the proof information of the i+1 interval; the second reference block refers to a block in the i+1 interval whose block height is 1 less than that of the target block in the i+1 interval;
[0295] Calculating the block header hash of the target block in the i+1 interval according to the block header hash of the second reference block;
[0296] Comparing the calculated block header hash of the target block in the i+1 interval with the block header hash of the target block in the i interval contained in the output information of the zero-knowledge proof circuit in the proof information of the i+1 interval, to obtain a second comparison result;
[0297] If the first comparison result is a comparison success, and the second comparison result is a comparison success, it is determined that the second verification result is a verification success.
[0298] In an implementation manner, the one or more instructions in the computer readable storage medium are loaded by the processor 1301 and further perform the following steps:
[0299] In response to the transaction query event for the target transaction, a transaction query request is sent to the full-node, the transaction query request containing the block height corresponding to the target transaction, so that the full-node determines the block to which the target transaction belongs based on the block height corresponding to the target transaction;
[0300] The block header of the block to which the target transaction belongs and the proof information of the i+1th interval corresponding to the block to which the target transaction belongs returned by the full-node in response to the transaction query request are received;
[0301] Based on the block header of the block to which the target transaction belongs and the proof information of the i+1th interval, it is queried whether the target transaction exists in the block to which the target transaction belongs, and a query result is obtained;
[0302] The query result is output.
[0303] In an implementation manner, the transaction query event is an event generated when the transaction query information sent by the client is obtained; the transaction query information includes the transaction hash of the target transaction and the Merkle path of the target transaction; when the processor 1301 loads and executes one or more instructions in the computer readable storage medium based on the block header of the block to which the target transaction belongs and the proof information of the i+1th interval, and queries whether the target transaction exists in the block to which the target transaction belongs, the following steps are specifically executed:
[0304] The block header hash of the third reference block is obtained from the output information of the zero-knowledge proof circuit in the proof information of the i+1th interval, and the block header hash of the block to which the target transaction belongs is calculated according to the block header hash of the third reference block; the third reference block refers to the block with a block height of 1 less than that of the block to which the target transaction belongs in the i+1th interval;
[0305] If the calculated block header hash of the block to which the target transaction belongs is the same as the block header hash of the block to which the target transaction belongs in the output information of the zero-knowledge proof circuit in the proof information of the i+1th interval, a Merkle root is generated based on the transaction hash of the target transaction and the Merkle path of the target transaction;
[0306] If the generated Merkle root exists in the block header of the block to which the target transaction belongs, a query result is generated, and the query result is used to indicate that the target transaction exists in the block to which the target transaction belongs.
[0307] In an implementation manner, the target block refers to the block with the largest block height in the interval.
[0308] In another embodiment, the computer readable storage medium stores one or more instructions; the one or more instructions stored in the computer readable storage medium are loaded and executed by the processor 1301 to implement the corresponding steps in the above-mentioned blockchain network-based block synchronization method embodiments. In a specific implementation, the blockchain network includes full nodes and light nodes; the full nodes store a full blockchain, the full blockchain includes N intervals, N is an integer greater than 1, each interval includes one or more sequentially connected blocks, and each interval corresponds to a proof information respectively, the proof information is used to prove the correctness of the blocks in the corresponding interval; the light nodes store the block headers of part of the blocks in the full blockchain; the blockchain node device is a full node, and the one or more instructions in the computer readable storage medium are loaded and executed by the processor 1301 to implement the following steps:
[0309] receiving a block synchronization request sent by the light node;
[0310] in response to the block synchronization request, returning the block header of the target block in the i+1th interval on the full blockchain and the proof information of the i+1th interval to the light node, so that the light node verifies the proof information of the i+1th interval based on the block header of the target block in the i th interval and the block header of the target block in the i+1th interval; and after the proof information of the i+1th interval is verified successfully, the light node stores the block header of the target block in the i+1th interval in the storage space of the light node; i=1, 2…N-1.
[0311] In an implementation manner, the one or more instructions in the computer readable storage medium are loaded and executed by the processor 1301 to further implement the following steps:
[0312] obtaining a zero-knowledge proof circuit generated based on a to-be-proved proposition, the to-be-proved proposition being used to indicate verification of the correctness of the block headers of the part of the blocks in the full blockchain;
[0313] deploying a block synchronization contract, and in the process of deploying the block synchronization contract, dividing the plurality of sequentially connected blocks in the full blockchain into N intervals;
[0314] calling the block synchronization contract to set the state of the i+1th interval to an exclusive state, and extracting the block header hash of each block in the i+1th interval and the block header hash of the target block in the i th interval from the full blockchain; the target block in the i th interval refers to the block with the largest block height in the i th interval;
[0315] verifying the block header hash of each block in the i+1th interval and the block header hash of the target block in the i th interval according to the zero-knowledge proof circuit to generate the proof information of the i+1th interval;
[0316] store the proof information of the i+1th interval to the full amount blockchain.
[0317] In an implementation manner, the proof information of the i+1th interval includes: output information of the zero-knowledge proof circuit; one or more instructions in the computer readable storage medium are loaded by the processor 1301 and executed to perform the following steps when performing the verification processing according to the zero-knowledge proof circuit on the block header hash of each block in the i+1th interval and the block header hash of the target block in the i+1th interval:
[0318] obtain the block header hash of the first reference block in the i+1th interval from the full amount blockchain, and calculate the block header hash of the target block in the i+1th interval according to the block header hash of the first reference block; the first reference block refers to a block whose block height is less than the block height of the target block in the i+1th interval by 1;
[0319] For each block in the i+1th interval, the block header hash of each block is calculated using the block header hash of the previous block, and the block header hash of each block in the i+1th interval is obtained;
[0320] verify the calculated block header hash of the target block in the i+1th interval and the calculated block header hash of each block in the i+1th interval, and generate a circuit check result;
[0321] The output information of the zero-knowledge proof circuit includes: the block header hash of the target block in the i+1th interval calculated by the zero-knowledge proof circuit, the block header hash of each block in the i+1th interval calculated by the zero-knowledge proof circuit, and the circuit check result.
[0322] In an implementation manner, one or more instructions in the computer readable storage medium are loaded by the processor 1301 and executed to perform the following steps when performing the verification processing according to the zero-knowledge proof circuit on the block header hash of each block in the i+1th interval and the block header hash of the target block in the i+1th interval:
[0323] compare the block header hash of the target block in the i+1th interval calculated by the zero-knowledge proof circuit with the block header hash of the target block in the i+1th interval extracted from the full amount blockchain;
[0324] And compare the block header hash of each block in the i+1th interval calculated by the zero-knowledge proof circuit with the block header hash of the corresponding block in the i+1th interval extracted from the full amount blockchain;
[0325] If the comparison results are both successful, a circuit checking result is generated, and a value of the circuit checking result is a preset value, indicating that the block header hash calculated by the zero-knowledge proof circuit matches the block header hash of the corresponding block in the full-chain.
[0326] In an implementation manner, the proof information corresponding to the i+1th interval further includes a proof string; and the one or more instructions in the computer readable storage medium are loaded and further executed by the processor 1301 to perform the following steps:
[0327] obtaining a key generation algorithm, and generating a prover public string and a verifier public string according to the key generation algorithm; the prover public string is a key used by a prover, and the prover includes a full-node; the verifier public string is a key used by a verifier, and the verifier includes a light-node;
[0328] storing the verifier public string to the full-chain; and
[0329] generating a proof string for a calculation process of the zero-knowledge proof circuit for calculating the output information; and the generation of the proof string indicates that the full-node has executed the calculation process based on the zero-knowledge proof circuit.
[0330] In an implementation manner, the one or more instructions in the computer readable storage medium are loaded and further executed by the processor 1301 to perform the following steps:
[0331] releasing the exclusive state of the i+1th interval if it is detected that the proof information of the i+1th interval has been generated; or
[0332] releasing the exclusive state of the i+1th interval if a time duration of the i+1th interval in the exclusive state is greater than a time duration threshold since the i+1th interval is set to the exclusive state.
[0333] In the embodiments of the present application, the blockchain network includes full nodes and light nodes; wherein the full nodes store a full blockchain (e.g., a blockchain including block headers of all blocks), and a plurality of blocks sequentially connected in the full blockchain are divided into N intervals, N is an integer greater than 1. The light node can only synchronize the block header of the target block in the i+1th interval and the corresponding proof information on the full blockchain from the full node; then, the light node verifies the proof information of the i+1th interval based on the block header of the target block in the i th interval and the block header of the target block in the i+1th interval; when the proof information of the i+1th interval is verified successfully, it can be determined that each block in the i+1th interval is valid or legal. In the above scheme, only a small amount of block headers can be synchronized from the full blockchain of the full node, such as the block header of the genesis block and the block header of the target block in each interval, which can verify the validity of the full block header in the full blockchain according to a small amount of block headers, improve the efficiency of block synchronization and verification, reduce the overhead required for block synchronization of the light node, and reduce the burden of the light node.
[0334] The embodiments of the present application also provide a computer program product or computer program, which includes computer instructions stored in a computer readable storage medium. The processor of the blockchain node device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to make the blockchain node device execute the above-mentioned block synchronization method based on the blockchain network.
[0335] Those skilled in the art can be aware that the units and algorithm steps of each example described in combination with the embodiments disclosed in the present application can be realized in electronic hardware or a combination of computer software and electronic hardware. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0336] In the above embodiments, all or part of the embodiments can be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present application are generated. The computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in or transmitted by a computer readable storage medium. The computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center through wired (for example, coaxial cable, optical fiber, digital line (DSL)) or wireless (for example, infrared, wireless, microwave, etc.) manner. The computer readable storage medium can be any available medium that can be accessed by a computer or a data processing device such as a server, data center, etc. integrated with one or more available media. The available media can be magnetic media (for example, floppy disk, hard disk, magnetic tape), optical media (for example, DVD), or semiconductor media (for example, solid state disk (SSD)) and the like.
[0337] The above description is merely a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art can easily think of changes or replacements within the technical scope disclosed in the present application, which should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A block synchronization method based on a blockchain network, characterized in that, The blockchain network comprises full nodes and light nodes; the full nodes store a full blockchain, the full blockchain comprises N intervals, N is an integer greater than 1, each interval comprises one or more sequentially connected blocks, and each interval corresponds to a proof information, the proof information is used to prove the correctness of the blocks in the corresponding interval; The light nodes store block headers of part of the blocks in the full blockchain; The method is executed by the light node, and the method comprises: obtaining a block header of a target block in an i-th interval on the full blockchain, wherein the proof information of the i-th interval has been successfully verified, i = 1, 2, …, N-1; synchronizing, from the full node, a block header of a target block in an (i+1)-th interval on the full blockchain and synchronizing the proof information of the (i+1)-th interval; obtaining a verifier public key string from the full blockchain, and verifying a proof string in the proof information of the (i+1)-th interval by using the verifier public key string to obtain a first verification result; the verifier public string is a key used by a verifier, and the verifier comprises the light node; reading a value of a circuit check result from output information of a zero-knowledge proof circuit included in the proof information of the (i+1)-th interval, and verifying a block header hash included in the output information according to the block header of the target block in the i-th interval to obtain a second verification result; if the first verification result is a verification success, the value of the circuit check result is a preset value, and the second verification result is a verification success, it is determined that a verification result corresponding to the (i+1)-th interval is a verification success, and the block header of the target block in the (i+1)-th interval is stored in a storage space.
2. The method of claim 1, wherein, The full blockchain further comprises a genesis block; the method further comprises: synchronizing, from the full node, a block header of the genesis block on the full blockchain; when i = 1, verifying the proof information of the i-th interval according to the block header of the genesis block and the block header of the target block in the i-th interval; if the proof information of the i-th interval is verified successfully, storing the block header of the target block in the i-th interval in a storage space.
3. The method of claim 1, wherein, The method further comprises: concurrently obtaining, from the full node, block headers of target blocks in M intervals, M is an integer, M ∈ [1, N], and the i-th interval is any one of the M intervals; or obtaining the block header of the target block in the i-th interval from a storage space in the light node.
4. The method of claim 1, wherein, The proof information comprises a proof string and output information of a zero-knowledge proof circuit; the proof string is generated by the full node based on a proof verifier public string, and is used to generate a calculation process of the output information calculated by the zero-knowledge proof circuit; the generation of the proof string indicates that the full node has executed the calculation process based on the zero-knowledge proof circuit; The proof verifier public string is a key used by a proof verifier; The proof verifier comprises the full node. The output information of the zero-knowledge proof circuit includes: a block header hash of a target block in an i-th interval calculated by using the zero-knowledge proof circuit, a block header hash of each block in an (i+1)-th interval calculated by using the zero-knowledge proof circuit, and a circuit checking result. The circuit checking result is used to indicate whether the block header hash calculated by using the zero-knowledge proof circuit matches a block header hash of a corresponding block in the full-chain.
5. The method of claim 4, wherein, When the value of the circuit checking result is a preset value, the circuit checking result is used to indicate that the block header hash calculated by using the zero-knowledge proof circuit matches the block header hash of the corresponding block in the full-chain.
6. The method of claim 5, wherein, The verification of the block header hash contained in the output information of the zero-knowledge proof circuit in the proof information according to the block header of the target block in the i-th interval includes: obtaining a block header hash of a first reference block in the i-th interval from the proof information of the i-th interval; the first reference block refers to a block with a block height smaller than that of the target block in the i-th interval by 1; calculating the block header hash of the target block in the i-th interval according to the block header hash of the first reference block; comparing the calculated block header hash of the target block in the i-th interval with the block header hash of the target block in the i-th interval contained in the output information of the zero-knowledge proof circuit in the proof information of the i-th interval to obtain a first comparison result; obtaining a block header hash of a second reference block in the (i+1)-th interval from the proof information of the (i+1)-th interval; the second reference block refers to a block with a block height smaller than that of the target block in the (i+1)-th interval by 1; calculating the block header hash of the target block in the (i+1)-th interval according to the block header hash of the second reference block; comparing the calculated block header hash of the target block in the (i+1)-th interval with the block header hash of the target block in the (i+1)-th interval contained in the output information of the zero-knowledge proof circuit in the proof information of the (i+1)-th interval to obtain a second comparison result; if the first comparison result is a comparison success and the second comparison result is a comparison success, it is determined that the second verification result is a verification success.
7. The method of claim 1, wherein, The method further includes: in response to a transaction query event for a target transaction, sending a transaction query request to the full-chain node, the transaction query request containing a block height corresponding to the target transaction, so that the full-chain node determines a block to which the target transaction belongs based on the block height corresponding to the target transaction; receiving a block header of the block to which the target transaction belongs and proof information of an (i+1)-th interval corresponding to the block to which the target transaction belongs returned by the full-chain node in response to the transaction query request; query whether the target transaction exists in the block to which the target transaction belongs based on the block header of the block to which the target transaction belongs and the proof information of the i+1th interval, and obtain a query result; output the query result.
8. The method of claim 7, wherein, The transaction query event is an event generated when the transaction query information sent by the client is obtained. The transaction query information includes the transaction hash of the target transaction and the Merkle path of the target transaction. The query whether the target transaction exists in the block to which the target transaction belongs based on the block header of the block to which the target transaction belongs and the proof information of the i+1th interval, and obtain a query result, includes: obtain the block header hash of a third reference block from the output information of the zero-knowledge proof circuit in the proof information of the i+1th interval, and calculate the block header hash of the block to which the target transaction belongs according to the block header hash of the third reference block; the third reference block refers to a block in the i+1th interval whose block height is 1 less than that of the block to which the target transaction belongs; if the calculated block header hash of the block to which the target transaction belongs is the same as the block header hash of the block to which the target transaction belongs in the output information of the zero-knowledge proof circuit in the proof information of the i+1th interval, generate a Merkle root based on the transaction hash of the target transaction and the Merkle path of the target transaction; if the generated Merkle root exists in the block header of the block to which the target transaction belongs, generate a query result, which indicates that the target transaction exists in the block to which the target transaction belongs.
9. The method according to any one of claims 1 to 8, wherein, The target block refers to the block with the largest block height in the interval. 10.A block synchronization method based on a blockchain network, characterized in that, The blockchain network includes full nodes and light nodes; the full nodes store a full blockchain, the full blockchain includes N intervals, N is an integer greater than 1, each interval includes one or more sequentially connected blocks, and each interval corresponds to a proof information, which is used to prove the correctness of the blocks in the corresponding interval; The light nodes store the block headers of part of the blocks in the full blockchain; The method is executed by the full node, and the method includes: receiving a block synchronization request sent by the light node; in response to the block synchronization request, returning the block header of the target block in the i+1th interval on the full blockchain and the proof information of the i+1th interval to the light node, so that the light node verifies the proof information of the i+1th interval based on the block header of the target block in the i+1th interval and the block header of the target block in the i+1th interval; and after the proof information of the i+1th interval is verified successfully, the light node stores the block header of the target block in the i+1th interval in the storage space of the light node; i=1, 2…N-1; The process of verifying the proof information of the i+1 interval based on the block header of the target block in the i interval and the block header of the target block in the i+1 interval includes: obtaining a verifier public key string from the full-chain block chain, and verifying a proof string in the proof information of the i+1 interval by using the verifier public key string to obtain a first verification result; the verifier public key string is a key used by a verifier, and the verifier includes the lightweight node; reading a value of a circuit check result from output information of a zero-knowledge proof circuit included in the proof information of the i+1 interval, and verifying a block header hash included in the output information based on the block header of the target block in the i interval to obtain a second verification result; if the first verification result is a verification success, the value of the circuit check result is a preset value, and the second verification result is a verification success, it is determined that a verification result corresponding to the i+1 interval is a verification success.
11. The method of claim 10, wherein, The method further includes: obtaining a zero-knowledge proof circuit generated based on a proposition to be proved, the proposition to be proved being used to indicate that the correctness of the block headers of the partial blocks in the full-chain block chain is verified; deploying a block synchronization contract, and in the process of deploying the block synchronization contract, dividing a plurality of sequentially connected blocks in the full-chain block chain into N intervals; calling the block synchronization contract to set a state of the i+1 interval to an exclusive state, and extracting a block header hash of each block in the i+1 interval and a block header hash of a target block in the i interval from the full-chain block chain; the target block in the i interval refers to a block with the largest block height in the i interval; verifying the block header hash of each block in the i+1 interval and the block header hash of the target block in the i interval based on the zero-knowledge proof circuit to generate proof information of the i+1 interval; storing the proof information of the i+1 interval to the full-chain block chain.
12. The method of claim 11, wherein, The proof information of the i+1 interval includes: output information of the zero-knowledge proof circuit; the generation of the proof information of the i+1 interval based on the zero-knowledge proof circuit includes: obtaining a block header hash of a first reference block in the i interval from the full-chain block chain, and calculating a block header hash of a target block in the i interval based on the block header hash of the first reference block; the first reference block refers to a block with a block height that is 1 less than a block height of the target block in the i interval; for each block in the i+1 interval, calculating the block header hash of each block by using a block header hash of a previous block to obtain the block header hash of each block in the i+1 interval; The circuit checking result is generated by checking the block header hash of the target block in the ith interval calculated by the zero-knowledge proof circuit and the block header hash of each block in the (i+1)th interval calculated by the zero-knowledge proof circuit. The output information of the zero-knowledge proof circuit includes: the block header hash of the target block in the ith interval calculated by the zero-knowledge proof circuit, the block header hash of each block in the (i+1)th interval calculated by the zero-knowledge proof circuit, and the circuit checking result.
13. The method of claim 12, wherein, The circuit checking result is generated by checking the block header hash of the target block in the ith interval calculated by the zero-knowledge proof circuit and the block header hash of each block in the (i+1)th interval calculated by the zero-knowledge proof circuit. The block header hash of the target block in the ith interval calculated by the zero-knowledge proof circuit is compared with the block header hash of the target block in the ith interval extracted from the full-chain block chain. The block header hash of each block in the (i+1)th interval calculated by the zero-knowledge proof circuit is compared with the block header hash of the corresponding block in the (i+1)th interval extracted from the full-chain block chain. If the comparison results are both successful, the circuit checking result is generated, and the value of the circuit checking result is a preset value, indicating that the block header hash calculated by the zero-knowledge proof circuit matches the block header hash of the corresponding block in the full-chain block chain.
14. The method of claim 12, wherein, The proof information corresponding to the (i+1)th interval further includes a proof string. A key generation algorithm is obtained, and a prover public string and a verifier public string are generated according to the key generation algorithm; the prover public string is a key used by the prover, and the prover includes the full-node; the verifier public string is a key used by the verifier, and the verifier includes the light-node; The verifier public string is stored in the full-chain block chain; and A proof string is generated for the calculation process of the zero-knowledge proof circuit to obtain the output information; the generation of the proof string indicates that the full-node has executed the calculation process based on the zero-knowledge proof circuit.
15. The method of claim 11, wherein, The method further includes: If it is detected that the proof information of the (i+1)th interval has been generated, the exclusive state of the (i+1)th interval is released; or If the (i+1)th interval is in the exclusive state for a time duration greater than a time duration threshold since the (i+1)th interval is set to the exclusive state, the exclusive state of the (i+1)th interval is released. 16.A block synchronization apparatus based on a blockchain network, characterized in that, The blockchain network includes full-nodes and light-nodes; the full-nodes store a full-chain block chain, the full-chain block chain includes N intervals, N is an integer greater than 1, each interval includes one or more sequentially connected blocks, and each interval corresponds to a proof information, the proof information is used to prove the correctness of the blocks in the corresponding interval; The light-nodes store the block headers of part of the blocks in the full-chain block chain. The block synchronization device comprises: An acquisition unit is configured to acquire a block header of a target block in an i-th interval on the full-chain, wherein proof information of the i-th interval has been successfully verified; i=1, 2, …, N-1. A processing unit is configured to synchronize the block header of the target block in an i+1-th interval on the full-chain from the full-chain node, and synchronize the proof information of the i+1-th interval. The processing unit is further configured to acquire a verifier public key string from the full-chain, and verify a proof string in the proof information of the i+1-th interval by using the verifier public key string to obtain a first verification result; the verifier public string is a key used by a verifier, and the verifier includes the light node. A value of a circuit check result is read from output information of a zero-knowledge proof circuit included in the proof information of the i+1-th interval, and a block header hash included in the output information is verified according to the block header of the target block in the i-th interval to obtain a second verification result. If the first verification result is a verification success, the value of the circuit check result is a preset value, and the second verification result is a verification success, it is determined that a verification result corresponding to the i+1-th interval is a verification success, and the block header of the target block in the i+1-th interval is stored in a storage space. 17.A block synchronization apparatus based on a blockchain network, characterized in that, The block chain network includes a full-chain node and a light node; the full-chain node stores a full-chain, the full-chain includes N intervals, N is an integer greater than 1, each interval includes one or more sequentially connected blocks, and each interval corresponds to a proof information, the proof information is used to prove the correctness of the blocks in the corresponding interval. The light node stores a block header of part of the blocks in the full-chain. The block synchronization device comprises: A receiving unit is configured to receive a block synchronization request sent by the light node. A processing unit is configured to return, in response to the block synchronization request, a block header of a target block in an i+1-th interval on the full-chain and proof information of the i+1-th interval to the light node, so that the light node verifies the proof information of the i+1-th interval based on the block header of the target block in an i-th interval and the block header of the target block in the i+1-th interval; and after the proof information of the i+1-th interval is successfully verified, the light node stores the block header of the target block in the i+1-th interval in a storage space of the light node; i=1, 2, …, N-1. The process of verifying the proof information of the i+1 interval based on the block header of the target block in the i interval and the block header of the target block in the i+1 interval includes: obtaining a verifier public key string from the full amount blockchain, and verifying a proof string in the proof information of the i+1 interval by using the verifier public key string to obtain a first verification result; the verifier public string is a key used by a verifier, and the verifier includes the lightweight node; reading a value of a circuit check result from output information of a zero-knowledge proof circuit included in the proof information of the i+1 interval, and verifying a block header hash included in the output information based on the block header of the target block in the i interval to obtain a second verification result; if the first verification result is verification success, the value of the circuit check result is a preset value, and the second verification result is verification success, it is determined that a verification result corresponding to the i+1 interval is verification success.
18. A blockchain node device, comprising: Comprising: a processor adapted to execute a computer program; a computer readable storage medium having stored therein a computer program, the computer program, when executed by the processor, implements the block synchronization method based on the blockchain network according to any one of claims 1-9, or implements the block synchronization method based on the blockchain network according to any one of claims 10-15.
19. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is adapted to be loaded and executed by the processor to implement the block synchronization method based on the blockchain network according to any one of claims 1-9, or implement the block synchronization method based on the blockchain network according to any one of claims 10-15.
20. A computer program product, characterised in that, The computer program product includes computer instructions, and the computer instructions, when executed by the processor, implement the block synchronization method based on the blockchain network according to any one of claims 1-9, or implement the block synchronization method based on the blockchain network according to any one of claims 10-15.
Citation Information
Patent Citations
Data processing method, data processing device and storage medium
CN110400142A
Method and device for data synchronization in blockchain network and computing equipment
CN111061813A