CN116483915A - Block synchronization method, related device, medium and program product - Google Patents

Block synchronization method, related device, medium and program product Download PDF

Info

Publication number
CN116483915A
CN116483915A CN202210039428.1A CN202210039428A CN116483915A CN 116483915 A CN116483915 A CN 116483915A CN 202210039428 A CN202210039428 A CN 202210039428A CN 116483915 A CN116483915 A CN 116483915A
Authority
CN
China
Prior art keywords
block
interval
full
target
node
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210039428.1A
Other languages
Chinese (zh)
Inventor
刘汉卿
王宗友
蓝虎
朱耿良
时一防
廖志勇
张劲松
刘区城
郭英杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202210039428.1A priority Critical patent/CN116483915A/en
Publication of CN116483915A publication Critical patent/CN116483915A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Computing Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Bioethics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Hardware Design (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the application discloses a block synchronization method, a related device, a medium and a program product, wherein the method comprises the following steps: acquiring the block head of a target block in the ith interval on the full block chain, wherein the proof information of the ith interval is verified successfully; i=1, 2 … N-1; synchronizing the block head of the target block in the (i+1) th interval on the full block chain from the full node, and synchronizing the certification information of the (i+1) th interval; 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; if the proof information of the (i+1) th interval is verified successfully, the block head of the target block in the (i+1) th interval is stored into the storage space. By adopting the embodiment of the invention, the rate of the node synchronization block can be improved, the cost required by the synchronization block is reduced, and the node burden is reduced.

Description

Block synchronization method, related device, medium and program product
Technical Field
The present disclosure relates to the field of computer technology, and in particular, to a block synchronization method based on a block chain network, a block synchronization device based on a block chain network, a block chain node device, a computer readable storage medium, and a computer program product.
Background
A blockchain network is a data sharing system that supports distributed storage, where nodes in the blockchain network synchronize blocks from a full block chain (e.g., a blockchain that includes the block header of all blocks) to achieve distributed storage of data contained in the blocks.
In the prior art, nodes in the blockchain network need to synchronize each block in sequence according to the connection sequence of the blocks from the full blockchain to confirm the validity of the blocks in the full blockchain. However, practice finds that the cost of synchronizing each block by the node according to the connection sequence of each block in the full-quantity block chain is large, so that the block synchronization rate is reduced, and the burden of the node is increased.
Disclosure of Invention
The embodiment of the application provides a block synchronization method, a related device, a medium and a program product, which can improve the rate of node synchronization blocks, reduce the cost required by the synchronization blocks and reduce the node burden.
In one aspect, an embodiment of the present application provides a block synchronization method based on a blockchain network, where the blockchain network includes a full-scale node and a lightweight node; the full-quantity node stores a full-quantity blockchain, wherein the full-quantity blockchain comprises N sections, N is an integer larger than 1, each section comprises one or more blocks connected in sequence, each section corresponds to one piece of proving information, and the proving information is used for proving the correctness of the blocks in the corresponding section; the lightweight nodes store block heads of partial blocks in the full-volume block chain; the method is performed by a lightweight node, the method comprising:
Acquiring the block head of a target block in the ith interval on the full block chain, wherein the proof information of the ith interval is verified successfully; i=1, 2 … N-1;
synchronizing the block head of the target block in the (i+1) th interval on the full block chain from the full node, and synchronizing the certification information of the (i+1) th interval;
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;
if the proof information of the (i+1) th interval is verified successfully, the block head of the target block in the (i+1) th interval is stored into the storage space.
In the embodiment of the application, the blockchain network comprises a full-quantity node and a lightweight node; the full-volume node stores therein a full-volume blockchain (e.g., a blockchain including block heads of all blocks), and a plurality of blocks sequentially connected in the full-volume blockchain are divided into N sections, where N is an integer greater than 1. The lightweight node can synchronize the block header of the target block and corresponding certification information in the (i+1) th interval on the full block chain from the full node only; then, the lightweight node verifies 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; 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 scheme, the block heads of a small number of blocks can be synchronized from the full-volume block chain of the full-volume node, for example, the block heads of the synchronous generation blocks and the block heads of the target blocks in each interval can be verified according to the small number of block heads, so that the efficiency of block synchronization and verification is improved, the cost required by the block synchronization of the light-weight node is reduced, and the load of the light-weight node is lightened.
On the other hand, the embodiment of the application provides a block synchronization method based on a block chain network, wherein the block chain network comprises a total number of nodes and lightweight nodes; the full-quantity node stores a full-quantity blockchain, wherein the full-quantity blockchain comprises N sections, N is an integer larger than 1, each section comprises one or more blocks connected in sequence, each section corresponds to one piece of proving information, and the proving information is used for proving the correctness of the blocks in the corresponding section; the lightweight nodes store block heads of partial blocks in the full-volume block chain; the method is performed by a full-scale node, the method comprising:
receiving a block synchronization request sent by a lightweight node;
responding to a block synchronization request, returning the block head of a target block in the (i+1) th interval and the proof information of the (i+1) th interval on the full blockchain to the lightweight node, so that the lightweight node verifies the proof information of the (i+1) th interval based on the block head of the target block in the (i) th interval and the block head of the target block in the (i+1) th interval; after the proof information of the (i+1) th interval is successfully verified, the block head of the target block in the (i+1) th interval is stored into a storage space of the lightweight node by the lightweight node; i=1, 2 … N-1.
In the embodiment of the application, a full-volume node in a blockchain network can deploy a block synchronization contract to divide a plurality of blocks in the full-volume blockchain into N sections and regenerate the proving information of each section, so that a subsequent lightweight node can synchronize the block heads of only a small number of blocks in the full-volume blockchain, such as the block heads of target blocks in each section, and verify the proving information of the (i+1) th section, thereby realizing the verification of the validity of the full-volume block heads in the full-volume blockchain; the efficiency of block synchronization and verification is improved, the cost required by the block synchronization of the lightweight nodes is reduced, and the burden of the lightweight nodes is lightened.
On the other hand, the embodiment of the application provides a block synchronization device based on a block chain network, wherein the block chain network comprises a total number of nodes and lightweight nodes; the full-quantity node stores a full-quantity blockchain, wherein the full-quantity blockchain comprises N sections, N is an integer larger than 1, each section comprises one or more blocks connected in sequence, each section corresponds to one piece of proving information, and the proving information is used for proving the correctness of the blocks in the corresponding section; the lightweight nodes store block heads of partial blocks in the full-volume block chain; the block synchronization device is a lightweight node, and the device comprises:
The acquisition unit is used for acquiring the block head of the target block in the ith interval on the full blockchain, and the proof information of the ith interval is verified successfully; i=1, 2 … N-1;
the processing unit is used for synchronizing the block head of a target block in the (i+1) th interval on the full block chain from the full node and synchronizing the proof information of the (i+1) th interval;
the processing unit is further used for verifying the proof information of the (i+1) th interval based on the block head of the target block in the (i) th interval and the block head of the target block in the (i+1) th interval;
the processing unit is further configured to store the block header of the target block in the i+1th section to the storage space if the verification of the proof information of the i+1th section is successful.
In one implementation, the full blockchain also includes an creative block thereon; the processing unit is further used for:
synchronizing the block heads of the created blocks on the full-volume block chain from the full-volume nodes;
when i=1, verifying the proof information of the ith interval according to the block head of the created block and the block head of the target block in the ith interval;
if the verification of the proof information of the ith interval is successful, the block head of the target block in the ith interval is stored into the storage space.
In one implementation, the acquiring unit is configured to, when acquiring the block header of the target block in the ith interval on the full blockchain, specifically:
the method comprises the steps of concurrently obtaining block heads of target blocks in M sections from a total number of nodes, wherein M is an integer, M is E [1, N ], and an ith section is any one of the M sections; or alternatively, the process may be performed,
the block header of the target block in the ith section is obtained from the storage space in the lightweight node.
In one implementation, the certification information includes a certification string and output information of the zero knowledge certification circuit; the proving character string is generated by a calculation process of calculating the output information by a zero knowledge proving circuit based on the proving person public string by the full quantity node; the generation of the proving string represents: the full-quantity node proving that the circuit has executed a calculation process based on zero knowledge; the prover public string is the key used by the prover; the prover includes a full volume node;
wherein the output information of the zero knowledge proof circuit comprises: the zero knowledge proof circuit is adopted to calculate the block header hash of the target block in the ith interval, the zero knowledge proof circuit is adopted to calculate the block header hash of each block in the (i+1) th interval, and the circuit check result is adopted;
The circuit inspection result is used for indicating: and (3) whether the block head hash obtained by the calculation of the zero knowledge proof circuit is matched with the block head hash of the corresponding block in the full block chain or not.
In one implementation, the full blockchain has stored therein a verifier common string; the verifier-public string is the key used by the verifier; the verifier includes a lightweight node; the processing unit is configured to, when verifying the proof information of the i+1th section based on the block header of the target block in the i-th section and the block header of the target block in the i+1th section, specifically be:
obtaining a common string of a verifier from the full blockchain, and verifying a proving character string in proving information of the (i+1) th interval by adopting the common string of the verifier to obtain a first verification result;
reading the value of the circuit inspection result from the output information of the zero knowledge proof circuit contained in the proof information of the (i+1) th interval; the method comprises the steps of,
verifying the hash of the block head contained in the output information of the zero knowledge proof circuit in the proof information of the (i+1) th interval according to the block head of the target block in the (i) th interval to obtain a second verification result;
if the first verification result is verification success, the value of the circuit checking result is a preset value, and the second verification result is verification success, determining that the verification result corresponding to the (i+1) th interval is verification success;
When the value of the circuit check result is a preset value, the circuit check result is used for indicating: the block header hash calculated by the zero knowledge proof circuit is matched with the block header hash of the corresponding block in the full block chain.
In one implementation manner, the processing unit is configured to verify, according to a block header of a target block in an i-th interval, a block header hash included in output information of a zero knowledge proof circuit in proof information of an i+1th interval, where the second verification result is obtained, specifically configured to:
acquiring a block header hash of a first reference block in an ith interval from the proof information of the ith interval; the first reference block is a block having a block height 1 smaller than a block height of the target block in the i-th section;
calculating the block head hash of the target block in the ith interval according to the block head hash of the first reference block;
comparing the calculated block header hash of the target block in the ith interval with the output information of the zero knowledge proof circuit in the proof information of the ith interval, and obtaining a first comparison result;
Obtaining the block header hash of the second reference block in the (i+1) th interval from the proof information of the (i+1) th interval; the second reference block is a block having a block height in the i+1th section that is 1 smaller than the block height of the target block in the i+1th section;
calculating the block head hash of the target block in the (i+1) th interval according to the block head hash of the second reference block;
comparing the calculated block head hash of the target block in the (i+1) th interval with the output information of the zero knowledge proof circuit in the proof information of the (i+1) th interval, and comparing the block head hash of the target block in the (i) th interval with the output information of the zero knowledge proof circuit to obtain a second comparison result;
if the first comparison result is successful and the second comparison result is successful, determining that the second verification result is successful.
In one implementation, the processing unit is further configured to:
responding to a transaction inquiry event aiming at the target transaction, and sending a transaction inquiry request to the full-quantity node, wherein the transaction inquiry request comprises the block height corresponding to the target transaction, so that the full-quantity node determines the block to which the target transaction belongs based on the block height corresponding to the target transaction;
receiving the block head 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, wherein the block head of the block to which the target transaction belongs is returned by the full node in response to the transaction inquiry request;
Inquiring whether the target transaction exists in the block to which the target transaction belongs or not based on the block head of the block to which the target transaction belongs and the proof information of the (i+1) th interval, and obtaining an inquiry result;
and outputting the query result.
In one implementation, the transaction inquiry event is an event generated when transaction inquiry information sent by the client is acquired; the transaction inquiry information comprises a transaction hash of the target transaction and a merck path of the target transaction; the processing unit is configured to query whether a target transaction exists in a block to which the target transaction belongs based on a block header of the block to which the target transaction belongs and proof information of an i+1th interval, and when a query result is obtained, the processing unit is specifically configured to:
obtaining the block head hash of the third reference block from the output information of the zero knowledge proof circuit in the proof information of the (i+1) th interval, and calculating the block head hash of the block to which the target transaction belongs according to the block head hash of the third reference block; the third reference block is a block with a block height 1 smaller than the block height of the block to which the target transaction belongs in the (i+1) th interval;
if the calculated block head hash of the block to which the target transaction belongs is the same as the block head 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+1) th interval, generating a merck root based on the transaction hash of the target transaction and the merck path of the target transaction;
If the generated merck root exists in the block header of the block to which the target transaction belongs, a query result is generated, wherein the query result is used for indicating that the target transaction exists in the block to which the target transaction belongs.
In one implementation, the target block refers to a block with the largest block height within the interval.
In the embodiment of the application, the blockchain network comprises a full-quantity node and a lightweight node; the full-volume node stores therein a full-volume blockchain (e.g., a blockchain including block heads of all blocks), and a plurality of blocks sequentially connected in the full-volume blockchain are divided into N sections, where N is an integer greater than 1. The lightweight node can synchronize the block header of the target block and corresponding certification information in the (i+1) th interval on the full block chain from the full node only; then, the lightweight node verifies 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; 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 scheme, the block heads of a small number of blocks can be synchronized from the full-volume block chain of the full-volume node, for example, the block heads of the synchronous generation blocks and the block heads of the target blocks in each interval can be verified according to the small number of block heads, so that the efficiency of block synchronization and verification is improved, the cost required by the block synchronization of the light-weight node is reduced, and the load of the light-weight node is lightened.
On the other hand, the embodiment of the application provides a block synchronization device based on a block chain network, wherein the block chain network comprises a total number of nodes and lightweight nodes; the full-quantity node stores a full-quantity blockchain, wherein the full-quantity blockchain comprises N sections, N is an integer larger than 1, each section comprises one or more blocks connected in sequence, each section corresponds to one piece of proving information, and the proving information is used for proving the correctness of the blocks in the corresponding section; the lightweight nodes store block heads of partial blocks in the full-volume block chain; the block synchronization device is a full-scale node, and the device comprises:
the receiving unit is used for receiving the block synchronization request sent by the lightweight node;
the processing unit is used for responding to the block synchronization request, returning the block head of the target block in the (i+1) th interval and the proof information of the (i+1) th interval on the full block chain to the lightweight node, so that the lightweight node verifies the proof information of the (i+1) th interval based on the block head of the target block in the (i) th interval and the block head of the target block in the (i+1) th interval; after the proof information of the (i+1) th interval is successfully verified, the block head of the target block in the (i+1) th interval is stored into a storage space of the lightweight node by the lightweight node; i=1, 2 … N-1.
In one implementation, the processing unit is further configured to:
acquiring a zero knowledge proof circuit generated based on a proposition to be proved, wherein the proposition to be proved is used for indicating to verify the correctness of the block heads of partial blocks in the full block chain;
deploying the block synchronization contract, and dividing a plurality of blocks connected in sequence in the full block chain into N intervals in the process of deploying the block synchronization contract;
invoking a block synchronization contract to set the state of the (i+1) th interval to be an exclusive state, and extracting the block header hash of each block in the (i+1) th interval and the block header hash of a target block in the (i) th interval from the full blockchain; the target block in the ith section is the block with the largest block height in the ith section;
according to the zero knowledge proving circuit, verifying the block head hash of each block in the (i+1) th interval and the block head hash of the target block in the (i) th interval to generate proving information of the (i+1) th interval;
and (5) storing the proof information of the (i+1) th interval into the full blockchain.
In one implementation, the proof information for the (i+1) th interval includes: zero knowledge proof circuit output information; the processing unit is configured to perform verification processing on the block header hash of each block in the i+th interval and the block header hash of the target block in the i+th interval according to the zero knowledge proof circuit, and is specifically configured to:
Obtaining the block head hash of a first reference block in the ith interval from the full block chain, and calculating the block head hash of a target block in the ith interval according to the block head hash of the first reference block; the first reference block is a block having a block height 1 smaller than a block height of the target block in the i-th section;
for each block in the (i+1) th interval, calculating the block header hash of each block by adopting the block header hash of the previous block to obtain the block header hash of each block in the (i+1) th interval;
verifying the calculated block header hash of the target block in the ith interval and the calculated block header hash of each block in the (i+1) th interval to generate a circuit checking result;
wherein the output information of the zero knowledge proof circuit comprises: the block header hash of the target block in the i-th section calculated by the zero knowledge proof circuit is used, the block header hash of each block in the i+1-th section calculated by the zero knowledge proof circuit is used, and the circuit check result is obtained.
In one implementation manner, the processing unit is configured to 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, and when generating the circuit check result, specifically is configured to:
Comparing the block header hash of the target block in the i-th section calculated by the zero knowledge proof circuit with the block header hash of the target block in the i-th section extracted from the full blockchain;
and comparing 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;
if the comparison results are successful, generating a circuit check result, wherein the value of the circuit check result is a preset value for indicating: the block header hash calculated by the zero knowledge proof circuit is matched with the block header hash of the corresponding block in the full block chain.
In one implementation, the proof information corresponding to the (i+1) th interval further includes: a certification string; the processing unit is further used for:
acquiring 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, which includes a full number of nodes; the verifier-public string is a key used by a verifier, which comprises lightweight nodes;
Storing the verifier common string to a full blockchain; the method comprises the steps of,
based on the prover public string, a proving character string generated in the calculation process of the output information is obtained by the calculation of the zero knowledge proving circuit; the generation of the proving string represents: the full-scale nodes prove that the circuit has performed a calculation process based on zero knowledge.
In one implementation, the processing unit is further configured to:
if the proof information of the (i+1) th interval is detected to be generated, releasing the exclusive state of the (i+1) th interval; or alternatively, the process may be performed,
and if the time length of the (i+1) th section in the exclusive state is greater than the time length threshold value from the time when the (i+1) th section is set in the exclusive state, releasing the exclusive state of the (i+1) th section.
In the embodiment of the application, a full-volume node in a blockchain network can deploy a block synchronization contract to divide a plurality of blocks in the full-volume blockchain into N sections and regenerate the proving information of each section, so that a subsequent lightweight node can synchronize the block heads of only a small number of blocks in the full-volume blockchain, such as the block heads of target blocks in each section, and verify the proving information of the (i+1) th section, thereby realizing the verification of the validity of the full-volume block heads in the full-volume blockchain; the efficiency of block synchronization and verification is improved, the cost required by the block synchronization of the lightweight nodes is reduced, and the burden of the lightweight nodes is lightened.
In another aspect, the present application provides a blockchain node device, the device comprising:
a processor for loading and executing the computer program;
a computer readable storage medium having a computer program stored therein, which when executed by a processor, implements the blockchain network-based blocksynchronization method described above.
In another aspect, the present application provides a computer readable storage medium storing a computer program adapted to be loaded by a processor and to perform the form generating method described above.
In another aspect, the present application provides a computer program product or computer program comprising 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 cause the blockchain node device to perform the blockchain network-based blocksynchronization method described above.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the invention, and that other drawings can be obtained according to these drawings without inventive effort for the person skilled in the art.
FIG. 1a illustrates a block chain architecture diagram provided in accordance with one exemplary embodiment of the present application;
FIG. 1b illustrates a schematic diagram of a data sharing system according to an exemplary embodiment of the present application;
FIG. 1c illustrates an architecture diagram of a two-tier blockchain network provided by an exemplary embodiment of the present application;
FIG. 2 illustrates a flow diagram of a block synchronization scheme based on a blockchain network provided by an exemplary embodiment of the present application;
FIG. 3 is a schematic diagram of a zero knowledge proof circuit in accordance with an exemplary embodiment of the present application;
FIG. 4 illustrates a schematic diagram of partitioning a plurality of blocks contained in a full blockchain into N bins according to an exemplary embodiment of the present application;
FIG. 5 is a schematic diagram illustrating a calculation process of a zero knowledge proof circuit in accordance with an exemplary embodiment of the present application;
FIG. 6 is a flow chart of a block synchronization method based on a blockchain network according to an exemplary embodiment of the present application;
FIG. 7a is a schematic diagram of a block header of a target block in a lightweight node concurrency acquisition interval according to an exemplary embodiment of the present application;
FIG. 7b is a block header diagram of a target block in a lightweight node concurrency acquisition interval according to an exemplary embodiment of the present application;
FIG. 8 is a schematic diagram of a method for serially verifying certification information for each interval according to an exemplary embodiment of the present application;
FIG. 9 is a diagram of a block header for sequentially storing blocks according to an exemplary embodiment of the present application;
FIG. 10 is a flow chart of a block synchronization method based on a blockchain network according to an exemplary embodiment of the present application;
FIG. 11 is a block diagram of a block synchronization device based on a block chain network according to an exemplary embodiment of the present application;
FIG. 12 is a block diagram of a block synchronization device based on a block chain network according to an exemplary embodiment of the present application;
fig. 13 is a schematic structural diagram of a blockchain node device according to an exemplary embodiment of the present application.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by a person of ordinary skill in the art based on the embodiments of the invention without making any inventive effort, are intended to fall within the scope of the invention.
The embodiment of the application relates to a Blockchain (Blockchain), which is the basis of a Blockchain technology, and is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. The blockchain is essentially a decentralised database, which is a series of data blocks generated by cryptographic methods, each data block containing a batch of information of network transactions for verifying the validity (anti-counterfeiting) of the information and generating the next block. Referring to fig. 1a, as shown in fig. 1a, a block chain 101 is composed of a plurality of blocks, wherein a first block of the block chain is called an creation block (which may be simply called an creation block), the creation block comprises 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, and the block body stores input information; the next block of the created block takes the created block as a father block, the next block also comprises a block head and a block body, the block head is stored with the input information characteristic value of the current block, the block head characteristic value of the father block, the version number, the timestamp and the difficulty value, and the like, so that the block data stored in each block in the block chain are associated with the block data stored in the father block, and the safety of the input information in the block is ensured.
The blockchain may be maintained by blockchain nodes included in the blockchain network; where a blockchain network is understood to mean a data sharing system, meaning a system for sharing data between blockchain nodes, an exemplary architecture of the data sharing system can be seen in FIG. 1b; as shown in fig. 1b, a data sharing system may include a plurality of blockchain nodes 101, where each blockchain node 101 may be a server that is connected to the blockchain network, or may be a terminal (e.g., a client running in a terminal) that is connected to the blockchain network, and the specific form of the blockchain node 101 is not limited herein. For each blockchain node 101 in the blockchain network, there is a node identification corresponding thereto, and each blockchain node 101 in the blockchain network may store the node identifications of other blockchain nodes 101 in the blockchain network for subsequent broadcasting of the generated block to other blockchain nodes 101 in the data sharing system based on the node identifications of the other blockchain nodes 101. Each blockchain node 101 can maintain a node identification list, and correspondingly store the node name and the node identification into the node identification list; the node identification list can be seen in table 1:
TABLE 1
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
As shown in table 1, the node identification may be an IP (Internet Protocol, protocol for interconnection between networks) address and any other information that can be used to identify the node; for example, the node identifier may also be a binary sequence code (e.g., 110001110), and table 1 is only illustrated by taking an IP address as an example. The block chain nodes in the block chain network are all maintained with node identification lists, when any common node (such as the block chain node with the common identification function) in the block chain network adds the block passing through the common identification to the full block chain, other nodes in the block chain network acquire the node identification of any common identification node from the maintained node identification lists, and the block passing through the common identification is synchronized from the full block chain according to the node identification of any common identification node so as to realize the synchronization of the data in the block chain network. In the embodiment of the present application, the blockchain of the block header including all the blocks provided by the common node is referred to as a full blockchain.
The blockchain network provided in the embodiment of the present application includes a full-scale node, where the full-scale node refers to: nodes storing a full amount of blockchains; that is, the full-size node is a node that needs to synchronize all blocks included in the full-size blockchain in sequence, starting from the created block of the full-size blockchain. For example: the full-volume node may refer to a consensus node in the blockchain network, which has a function of consensus on blocks, and the consensus node includes all block heads of the full-volume blockchain and a block body corresponding to each block head. And the following steps: the full-scale node may also refer to an SPV node (Special Purpose Vehicle, carrier) in a blockchain network, or referred to as a service node; the SPV node refers to a node that stores the block header of each block in the full blockchain; specifically, the full block header in the full blockchain and the partial block (or transaction data) which is authorized to be acquired are stored, and the complete full blockchain is not stored.
In practical applications, a large number of service functions need to be borne by all nodes in the blockchain network, for example, all nodes are service nodes, and a large number of inquiry requests may need to be borne by the service nodes; for example, in an invoice service, the query request may be sent by the client to the service node for requesting a query as to whether the invoice transaction is present in the full blockchain. However, when the service node queries whether the transaction is uplink, it is not necessary to query each block in the full blockchain, and thus it is not necessary for the service node to download all blocks in the full blockchain. Therefore, if the business function of inquiring the existence of the transaction (or other business functions which do not need all the block heads in the full-scale blockchain) can be stripped from the full-scale nodes bearing a large number of business functions, the burden of the full-scale nodes can be reduced to a certain extent, and the expenditure of the full-scale nodes can be saved. Further, when the full-quantity node cannot synchronize a block with a certain block height from the full-quantity blockchain, confirming that the block head of the block is a legal block head; and only when the hash of the block header including the previous block header is verified, the block header of the block can be determined to be legal. This makes it necessary for the full-size node to synchronize all blocks in turn, starting from the created blocks of the full-size blockchain, in the order in which the blocks are connected, even though it only assumes the business function of querying the existence of a transaction (or other business functions that do not require all blocks). Therefore, if all block heads are not needed to be synchronized from the full blockchain for the node with the business function of inquiring the existence of the transaction, the storage cost of the node can be greatly reduced, and the business processing efficiency is improved.
Based on the above description about the full-scale nodes, the embodiments of the present application provide a block synchronization scheme based on a blockchain network, in which lightweight nodes are introduced into the blockchain network, that is, the blockchain network related to the embodiments of the present application includes lightweight nodes and the aforementioned full-scale nodes. Lightweight nodes in a blockchain network may be used to assume some business functions that do not require synchronization of the full amount of data (e.g., all of the blockheads in the full amount blockchain), e.g., lightweight nodes may be used to assume business functions that query for the existence of transactions; this may enable stripping of part of the traffic functions from the full-scale nodes (e.g., traffic nodes), reducing the burden on the full-scale nodes. In addition, compared with the full-volume node, the lightweight node can verify the validity of the full-volume data (such as all data in the full-volume blockchain) in the blockchain network without synchronizing all blocks or blockheads in the full-volume blockchain and only with synchronizing small block heads in the full-volume blockchain, so that the storage cost of the lightweight node and the expenditure of the synchronized blocks are greatly reduced. Wherein validity may be referred to as correctness or legality; when the block header of a block contains a block header hash of a previous block, it indicates that the block header of the block is legal (or valid, correct), thereby determining that the connection order of the block in the full blockchain is correct, and also determining that the block data in the block of the block is secure.
The lightweight nodes mentioned in the embodiments of the present application may be terminals that access to a blockchain network, or servers that access to the blockchain network. Wherein the terminal may include, but is not limited to: smart phones (such as Android mobile phones, iOS mobile phones, etc.), tablet computers, portable computers, mobile internet devices (Mobile Internet Devices, abbreviated as MID), smart televisions, vehicle-mounted devices, head-mounted devices, and other smart devices capable of performing touch screens. The server may include, but is not limited to: data processing servers, web servers, application servers, and the like, have complex computing capabilities. The embodiments of the present application are not limited to a specific type of lightweight nodes in a blockchain network, and are specifically described herein.
To facilitate a better understanding of lightweight nodes and full-scale nodes in a blockchain network, the types of blockchain networks that include lightweight nodes are described below. The lightweight node provided by the embodiment of the application can belong to a node of any one of the sub-networks in the double-layer or multi-layer network; "layer" herein refers to the number of sub-networks that the blockchain network contains; the division of the sub-networks may be due to traffic demands, communication connections, security, etc.; mutual access between blockchain nodes belonging to the same sub-network has a consensus mechanism to ensure security, while mutual access between blockchain nodes in different sub-networks requires additional identity management and/or network control. For example, when a blockchain is applied in some scenarios, such as: bill service scenarios, government or business data storage scenarios, etc.; in these scenarios, not all nodes in the blockchain network have sufficient resources and necessity to become nodes that perform blockchain consensus. For the safety of data, when important data is involved in a blockchain hierarchy, a common data peer-to-peer blockchain deployment mode is not applicable. In order to adapt to service requirements (such as an internal network, an external network, a service network, an office network separation and the like) and further improve the safety and confidentiality of data, a double-layer chain can be adopted, namely, a double-layer network architecture of 'witness sub-network-consensus sub-network' is formed through a P2P (Peer to Peer) network to improve the safety of the data; wherein the P2P network is a network of point-to-point connections, each node of which is called a peer node. The P2P network is based on a specific network protocol, so that a central node is not required between peer nodes to maintain network state, and each node maintains node state of the whole network and connection state of the node with adjacent nodes through broadcasting interaction with the adjacent nodes.
FIG. 1c illustrates an architecture diagram of a two-tier blockchain network provided by an exemplary embodiment of the present application; as shown in fig. 1c, the blockchain network includes a witness sub-network and a consensus sub-network, and the lightweight node provided in the embodiment of the present application may be accessed into the witness sub-network. Wherein: (1) the witness sub-network includes service nodes and/or lightweight nodes. The service nodes in the witness sub-network mainly perform service execution (such as the lightweight nodes are used for inquiring whether the transaction is uplink or not), do not perform accounting consensus, and acquire block head and/or block data visible by partial authorization from the consensus sub-network in an identity authentication mode. (2) The consensus sub-network is a core network in the blockchain network for accounting consensus of the blockchain network. The consensus sub-network comprises one or more consensus nodes (or called billing nodes) for consensus the block to realize the uplink of the block. Further, the witness sub-network and the consensus sub-network may interact through a routing agent network (or referred to as a routing border network) therebetween; the routing agent network is used for carrying out network isolation on the witness sub-network and the consensus sub-network; the routing proxy network comprises one or more routing proxy nodes, so that the data sent by the service nodes in the witness sub-network can be forwarded to the consensus nodes in the consensus sub-network through the routing proxy nodes, and the security of the data in the consensus sub-network can be improved.
It should be noted that, in the above-provided two-layer network structure, the aforementioned full-scale node may refer to a service node in the witness sub-network, where the light-weight node and the full-scale node (such as the service node) belong to the same network (such as the witness sub-network); the full-scale node may also refer to a consensus node in the consensus sub-network, where the light-weight node and the full-scale node (such as the consensus node) belong to different sub-networks, and data interaction between the light-weight node and the full-scale node (such as the light-weight node synchronizing a block header from the full-scale node) is implemented by a routing agent network between the witness sub-network and the consensus sub-network, and in particular, a routing agent node in the routing agent network. The embodiment of the application does not limit whether the total number of nodes are specifically service nodes in the witness sub-network or consensus nodes in the consensus sub-network, and is described herein. When the full-quantity node is a service node, the full-quantity node and the light-weight node belong to the same sub-network (namely a witness sub-network), and the blockchain network is understood to be a single-layer network at the moment; for example, the blockchain network shown in FIG. 1b is a single-layer blockchain network in which secure access and data synchronization may be achieved between the blockchain nodes through a consensus mechanism. The embodiments of the present application are not limited to the type of blockchain network to which the lightweight nodes specifically belong, and are described herein.
In a specific implementation, the block synchronization scheme based on the blockchain network provided by the embodiment of the application is implemented based on a zero knowledge proof (zeroknowledge proof, zkp) technology; in particular according to Zero-knowledge compact non-interactive knowledge demonstration (Zero-Knowledge Succinct Non-Interactive Argument ofKno wledge, zk-snark) technology. Wherein zero knowledge proof is a protocol involving two or more parties, i.e., a series of steps that two or more parties need to take to complete a task; for example, the two parties involved in the zero knowledge proof may include: a prover (e.g., an object that demonstrates the correctness of a certain argument) and a verifier (e.g., an object that verifies whether the proof provided by the prover for a certain argument is correct); in embodiments of the present application, the prover may include a full amount of nodes in the blockchain network (i.e., nodes that include a full amount of blockchains), and the verifier may include a lightweight node in the blockchain network (i.e., nodes that include only the blockheads of a portion of the blocks in the full amount of blockchains). In a zero knowledge proof process, the prover can conduct multiple data interactions with the verifier without providing any useful information to the verifier, so that the verifier believes the correctness of a certain assertion. A non-interactive knowledge proof of zero knowledge is also a protocol involving two or more parties that can make a judgment on the correctness of a certain proof. However, unlike zero knowledge proof, the conclusive non-interactive knowledge proof of zero knowledge is to achieve the goal of non-interaction at the expense of bearing a certain dispute; in other words, in the process of one non-interactive knowledge demonstration with simple zero knowledge, only one data interaction is performed between the prover and the verifier, so that judgment on the correctness of the demonstration can be realized.
The embodiment of the application realizes the block synchronization scheme based on the blockchain network by using a non-interactive knowledge demonstration technology with simple zero knowledge, and particularly enables a light-weight node (i.e. a verifier) to verify under the condition of synchronizing and a small number of block heads from the whole blockchain only by using the non-interactive knowledge demonstration technology with simple zero knowledge: (1) the correctness of the downloaded block header; (2) when h i ,h j Verifying h pulled from full nodes for block height of two adjacent downloaded block heads i ,h j The block header between the block heights is correct, i, j belong to the values corresponding to the two block heights in the full blockchain, and i is larger than j. That is, by non-interactive knowledge proof of zero knowledge, a prover (e.g., a full-size node) is enabled to trust the validity of the full-size data in the full-size blockchain by sending the data (e.g., the blockhead of a portion of the blocks in the full-size blockchain) to a verifier (e.g., a lightweight node). The block synchronization scheme provided by the embodiment of the application is simply introduced by combining the operation principle of zero-knowledge compact non-interactive knowledge demonstrationThe principle of operation can be divided into four steps in principle, including:
1) The full number of nodes in the blockchain network may translate the proposition to be demonstrated into a zero knowledge proof circuit. The proposition to be proved can refer to a proposition to be judged or verified between a verifier and a verifier. Specifically, an operator can be adopted to express the operation logic corresponding to the proposition to be proved so as to obtain a zero knowledge proving circuit corresponding to the proposition to be proved.
2) The full population of nodes in the blockchain network use a generation algorithm to generate common parameters, prover keys, and verifier keys for the proposition to be proved. The prover key and the verifier key are generated (e.g., can be acquired by any node in the blockchain network), so that the prover key is called a prover public string, the verifier key is called a verifier public string, and the two references are not limited in the following description. The common parameters are character strings which are randomly generated by adopting a generation algorithm and cannot be revealed, and have important influence on the security of the proving process.
3) The full number of nodes in the blockchain network generate proof information through a prover key and a zero knowledge proof circuit (i.e., an R1CS circuit into which a proposition to be proved is converted).
4) The lightweight nodes in the blockchain network adopt verifier keys to verify the certification information generated by the full quantity of nodes; when the verification information is successfully verified, the verifier determines that the data provided by the prover is valid, such as the lightweight node determines that the block header of a part of the blocks synchronized from the full blockchain of the full node is legal; conversely, when the validation of the validation information fails, the validator determines that the data provided by the validator is invalid, e.g., the lightweight node determines that the tile head of a tile synchronized from the full blockchain of the full node is illegal.
In steps 2) -4), the generation algorithm included in the non-interactive knowledge proof of zero knowledge conciseness may include: a key generation algorithm, a prover algorithm, and a verifier algorithm. Wherein: the key generation algorithm may generate a prover key and a verifier key based on the common parameters; the prover algorithm may generate proof information for the proposition to be demonstrated based on the prover key; the verifier algorithm may verify the prover-generated attestation information based on the verifier key, resulting in a verification result, which may also be referred to as a circuit check result.
It should be noted that the above description is only a simple introduction of the operation principle of the non-interactive knowledge demonstration for conciseness of zero knowledge; in the practical application scene, the operation principle of the non-interactive knowledge demonstration with simple zero knowledge also comprises other contents. For example, the above description is given only as an example for the relevant introduction of three algorithms involved in the non-interactive knowledge demonstration of zero knowledge conciseness; in the process of generating the key by the key generation algorithm, the key generation algorithm generates the prover key and the verifier key based on the public parameter, and the key generation algorithm also relates to information such as a program for generating the key, and the like; the embodiments of the present application are not described in detail herein.
Based on the above description of the non-interactive knowledge demonstration of the nulling knowledge, the following embodiments are respectively adopted with reference to the accompanying drawings: the implementation process of generating the certification information by the certifier (such as the full-quantity node), the implementation process of verifying the certification information generated by the certifier (such as the light-weight node), and the implementation process of executing the business function (such as the business function of inquiring the existence of the transaction) by the certifier are described in detail. The implementation of generating attestation information for a full population of nodes in a blockchain network is described below in conjunction with FIG. 2; FIG. 2 illustrates a flow diagram of a block synchronization scheme based on a blockchain network provided by an exemplary embodiment of the present application; the block synchronization scheme may be performed by a full number of nodes in the blockchain network, and may specifically include, but is not limited to, steps S201-S204:
s201: and acquiring a zero knowledge proving circuit generated based on the proposition to be proving.
As described above, the embodiments of the present application are based on a non-interactive knowledge demonstration technology with zero knowledge conciseness, so that the lightweight node can verify only if the block header of a small number of blocks is synchronized from the full blockchain: the correctness of the block header of the downloaded block; and the correctness of the block header between the block headers of the two adjacent blocks downloaded. Based on this, the propositions to be proven referred to in the embodiments of the present application can be summarized simply as: and verifying the correctness of the block heads of the partial blocks in the full-volume block chain and the correctness of each block head among the block heads of the partial blocks. When the zero-knowledge proof circuit is obtained by initializing all nodes in the blockchain network based on the proposition to be proved, if the arithmetic logic corresponding to the proposition to be proved is expressed by adopting one or more arithmetic algorithms, the initialization of the zero-knowledge proof circuit can be realized, and 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 expressed simply as: for each block header in the block header of a partial block in the full-volume block chain, calculating a block header hash of the 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 (namely, the block header hash of the partial block obtained from the full block chain); and generating a circuit inspection result according to the comparison result.
Wherein the zero knowledge proof circuit may be referred to as an arithmetic circuit (Rank One Constrain System, R1 CS); an exemplary zero knowledge proof circuit structure can be seen in fig. 3, which is composed of addition gates, multiplication gates and constant gates, and the zero knowledge proof circuit shown in fig. 3 includes two multiplication gates and one addition gate. In practical application, after input information is input into the zero knowledge proof circuit, operations can be sequentially executed according to each gate contained in the zero knowledge proof circuit to obtain output information of the zero knowledge proof circuit; the output information of the zero knowledge proof circuit can be simply understood as an answer obtained by solving the proposition to be proved. As shown in fig. 3, the input information is a, b, and c, and the addition gate included in the zero knowledge proof circuit can be used for adding a and b to obtain a+b, and the multiplication gate is used for multiplying b and c to obtain b×c; then, a+b and b×c are multiplied by a multiplier gate to obtain output information (a+b) ×b×c. It should be noted that some common computing logic, such as computing expressions, computing hash values, etc., may be represented as zero knowledge proof circuits.
It should be further noted that, in the embodiment of the present application, after the zero-knowledge-succinct non-interactive knowledge demonstration technology is initialized to obtain the zero-knowledge proving circuit, a key generation algorithm of the zero-knowledge succinct non-interactive knowledge demonstration technology may be further obtained, and a prover public string is generated for the prover and a verifier public string is generated for the verifier 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-common string is stored in the full blockchain to realize the uplink of the verifier-common string. And the zero knowledge proof circuit and the public string of the prover obtained by initialization are disclosed under a chain, such as the zero knowledge proof circuit and the public string of the prover are put into a certain website page, so that any node in the blockchain network with the full node for acquiring the authority and the requirement of the zero knowledge proof circuit and/or the public string of the prover can open the website page through the link address (such as the website address) of the website page to acquire the zero knowledge proof circuit and/or the public string of the prover.
S202: and deploying the block synchronization contract, and dividing a plurality of blocks connected in sequence in the full-quantity blockchain into N sections in the process of deploying the block synchronization contract.
Wherein, the chunk sync contract may be a contract named fastsync. The embodiment of the application supports the setting of the interval number in the process of deploying the block synchronization contract in the block chain network, in particular in the process of deploying the block synchronization contract in the total nodes in the block chain network; thus, the full-volume node can call the block synchronization contract to divide a plurality of blocks after the link to the created block in the full-volume block chain into a plurality of intervals. For example, in the process of deploying the block synchronization contract, assuming that the number of intervals is N, where N is an integer greater than 1, it is determined that a plurality of blocks in the full blockchain linked to the generated blocks are divided into N intervals, where each interval includes one or more blocks that are sequentially connected. Alternatively, in the process of deploying the block synchronization contract in the full-volume node, the number of sections may be set instead of the number of sections (or referred to as the section capacity), so that a plurality of blocks linked to the blocks after the creation of the block in the full-volume blockchain may be divided according to the set number of blocks in each section, to obtain a plurality of sections. For example, assuming that the number of blocks in each interval is set to 3 and the number of blocks in the full blockchain linked to the created block is 9 (i.e., the height of the blocks in the full blockchain is 10), the 9 blocks in the full blockchain linked to the created block can be divided into 3 intervals on average.
An exemplary diagram of partitioning a plurality of blocks contained in a full blockchain into N bins can be seen in fig. 4; as shown in fig. 4, assuming that the number of blocks per section, that is, the section capacity, set in the process of deploying the block synchronization contract is 3, each three blocks in the plurality of blocks linked to the generated block 401 in the full-volume blockchain may be divided into one section, that is, one section includes three blocks connected in sequence; the blocks that are sequentially connected in the full blockchain are: the creation block 401, the block 402, the block 403, the block 404, the … …, the block 405, the block 406, the block 407, and the … … can be set as a single section, and then each three blocks linked after the creation block 401 are divided into a section, for example, a first section includes the block 402, the block 403, the block 404, and a second section includes the block 405, the block 406, and the 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 may be the same or different, which is described herein.
As can be seen from the above description, in the embodiments of the present application, by deploying the block synchronization contract in the full-volume node, the full-volume node can divide a plurality of blocks, which are sequentially connected after creating the blocks, in the full-volume blockchain into N intervals by calling the block synchronization contract, so that the full-volume node can be ready for subsequent operations.
S203: and calling a block synchronization contract to set the state of the (i+1) th interval to be an exclusive state, and extracting the block header hash of each block in the (i+1) th interval and the block header hash of the target block in the (i) th interval from the full blockchain.
It should be noted that, the block synchronization contract deployed in the full-volume node includes one or more methods, and when different methods in the block synchronization contract are called, different functions can be implemented. The block synchronization contracts may include, but are not limited to, the following: a preparation method (preparation method), a revocation method (witdraw method), a storage proof method (saveProof method), and the like. Wherein, the preparation method can be used for setting a certain interval in the full blockchain to an exclusive state (or called a pending state); for example: when the full node wants to generate the proof information for the i+1th interval of the N intervals, the preparation method in the block synchronization contract can be invoked to set the i+1th interval to be in an exclusive state, when the i+1th interval is in a state of being exclusive by the full node, the full node has the operation authority (such as the authority of acquiring the information in the block header or the block header) on the block in the i+1th interval, and other full nodes in the blockchain network do not have the operation authority on the block in the i+1th interval. The revocation method can be used for cancelling or releasing the exclusive state of a certain interval, and when the exclusive state of the certain interval is released, all nodes in the blockchain network have the operation authority to the blocks in the certain interval. The storage proving method can be used for storing proving information generated by the full-quantity nodes for a certain interval; for example, after the full-size node generates the certification information for the i+1th interval, the full-size node may call the storage certification method in the block synchronization contract, store the certification information of the i+1th interval into the full-size blockchain, and drop the certification information into the storage space of the full-size node.
In a specific implementation, when the state of a certain section in the full blockchain is set to be in an exclusive state, and the state indicates that the full node wants to generate the proving information for the certain section, corresponding information can be extracted from the full blockchain to generate the proving information for the certain section. Taking the certain interval as the i+1th interval as an example, i=1, 2 … N-1, N is an integer greater than 1, when detecting that the full-size node sets the state of the i+1th interval in the full-size blockchain to be the exclusive state, the blockhead hash of each block in the i+1th interval and the blockhead hash of the target block in the i-th interval can be extracted from the full-size blockchain; the target block may be a block with the largest block height in the corresponding interval, i.e. the last block in the corresponding interval; for example, the target block in the i-th section refers to the block with the largest block height in the i-th section; for another example, the target block in the first section in fig. 4 is referred to as block 404, and the target block in the second section is referred to as block 407. It will be appreciated that the specific implementation of the full-scale node generating the certification information for each interval in the full-scale blockchain is similar; for convenience of explanation, the generation of certification information for the (i+1) th interval will be described later.
S204: and according to the zero knowledge proving circuit, verifying the block header hash of each block in the (i+1) th interval and the block header hash of the target block in the (i) th interval to generate proving information of the (i+1) th interval.
Based on the foregoing description, the zero-knowledge proof circuit is generated based on the proposition to be proven, and the zero-knowledge proof circuit is written with the operation logic for verifying the blocks in the interval; therefore, after the block header hash of each block in the i+1th section pulled from the full blockchain and the block header hash of the target block in the i-th section are input to the zero knowledge proof circuit, the proof information of the i+1th section can be generated directly based on the output information of the zero knowledge proof circuit. The proof information of the (i+1) th interval may include: the output information of the zero knowledge proof circuit corresponding to the (i+1) th interval, and a proof character string (or referred to as zk-snark proof). Wherein: (1) the output information of the zero knowledge proof circuit corresponding to the (i+1) th interval comprises: the block header hash of the target block in the i-th section calculated by the zero knowledge proof circuit is used, the block header hash of each block in the i+1-th section calculated by the zero knowledge proof circuit is used, and the circuit check result is obtained. Wherein, the chunk header hash of any chunk is generated according to the chunk header hash of the previous chunk of the any chunk and the parameters included in the chunk header of the any chunk, and the parameters included in the chunk header of the any chunk may include, but are not limited to: the block height of any block, the timestamp of any block, the merck root of any block, etc. (2) The proving character string is generated based on the calculation process that the proving person public string is zero knowledge proving circuit to calculate and obtain output information; that is, the attestation string may refer to the generation of an attestation string by the calculation process of the attestation circuit for zero knowledge, the generation of the attestation string being usable to represent: the full-scale nodes prove that the circuit has performed a calculation process based on zero knowledge. Wherein the proving string may be a string composed of a plurality of characters, which may include, but are not limited to: english characters (i.e., letters), numbers, and punctuation marks (e.g., comma ", period", bracket "," ") and the like.
In this embodiment of the present application, the generation process of the proving string in the proving information of the i+1th interval may refer to the related content described above, and in the following, in conjunction with fig. 5, a zero knowledge proving circuit is mainly provided to 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 interval, to obtain a calculation process of the output information of the zero knowledge proving circuit, where the calculation process may include steps s11-s13:
s11: for the chunk header of each chunk obtained from the full blockchain, the chunk header hash of each chunk is calculated using the chunk header hash of the previous chunk and parameters required to calculate the chunk header hash. The chunk header hash for each chunk involved in this step may include: a chunk header hash of the target chunk in the ith interval in the full blockchain, and a chunk header hash of each chunk in the (i+1) th interval.
As described above, the chunk header hash of any chunk is generated according to the chunk header hash of the previous chunk of the any chunk and the parameters contained in the chunk header of the any chunk (i.e. the parameters required for calculating the chunk header hash), and then the specific implementation process for generating the chunk header hash of each chunk may include: in one aspect, a block header hash of a first reference block in an ith interval is obtained from a full blockchain, the block header hash of the first reference block is stored in a block header of the first reference block, and the first reference block may be a block in the ith interval with a block height less than 1 of a block height of a target block in the ith interval, if the target block is a last block in the ith interval, then the first reference block is a block adjacent to the last block in the ith interval. Then, the block header hash of the target block in the i-th section is calculated from the block header hash of the first reference block in the i-th section. On the other hand, for each block in the (i+1) -th interval, calculating the block header hash of each block by adopting the block header hash of the previous block to obtain the block header hash of each block in the (i+1) -th interval; the block preceding the block with the smallest block height in the i+1th section (e.g., the first block in the i+1th section) is the target block in the i-th section. Through the implementation process shown in the two aspects, the block header hash of the target block in the ith interval can be calculated, and the block header hash of each block in the (i+1) th interval can be calculated.
s12: and verifying the calculated block header hash of the target block in the ith interval and the calculated block header hash of each block in the (i+1) th interval to generate a circuit checking result. In a specific implementation, the block header hash of the target block in the i-th section calculated by the zero knowledge proof circuit is compared with the block header hash of the target block in the i-th section extracted from the full blockchain. And comparing 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.
If the comparison results are all successful, i.e. the block header hash of the target block in the ith interval calculated by the zero knowledge proof circuit is matched (or identical) with the block header hash of the target block in the ith 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 is matched with the block header hash of the corresponding block in the (i+1) th interval extracted from the full blockchain, generating a circuit check result, wherein the value of the circuit check result is assigned to a preset value, if the preset value is true (or digital 1); when the value of the circuit inspection result is a preset value, the circuit inspection result can be used for indicating: the block header hash calculated by the zero knowledge proof circuit is matched with the block header hash of the corresponding block in the full block chain.
Conversely, if the comparison result is that the comparison fails, if the block header hash of the target block in the ith interval calculated by using the zero knowledge proof circuit does not match the block header hash of the target block in the ith interval extracted from the full blockchain, and/or if the block header hash of each block in the (i+1) th interval calculated by using 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 checking result is assigned to a non-preset value, and the non-budget value may be any value other than the preset value, such as false (or digital 0); when the value of the circuit inspection result is a non-preset value, the circuit inspection result may be used to indicate: the block header hash calculated by the zero knowledge proof circuit is not matched with the block header hash of the corresponding block in the full block chain.
s13: based on the calculated block header hash of the target block in the ith 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 formed.
By executing the implementation process shown in the steps s11-s13, the output information of the zero knowledge proof circuit can be obtained.
In addition, the embodiment of the application also supports that the exclusive state of the (i+1) -th interval is released or canceled after the proof information of the (i+1) -th interval is generated is detected; when the i+1th interval is not in the exclusive state, all the full nodes in the blockchain network can operate on the blocks in the i+1th interval, such as operations of synchronizing the blocks, acquiring the block heads and the like. Specifically, after detecting that the proof information of the (i+1) th interval has been generated, the full-quantity node may invoke a storage proof method (such as a saveProof method) in the deployed block synchronization contract, and set the state of the (i+1) th interval from an exclusive state (pending state) to a non-exclusive state (or referred to as a shared state). In addition to the above description, by the full-quantity node for making the certification information of the i+1th section, after detecting that the certification information of the i+1th section has been generated, the exclusive state of the i+1th section is actively released; the embodiment of the application also supports that when the (i+1) th interval is detected to be in the exclusive state for a long time, the exclusive state of the (i+1) th interval is released.
Alternatively, the process of releasing the exclusive state of the i+1th section may be performed by a full-quantity node for making the certification information of the i+1th section; when the state of the (i+1) th section is set to be the exclusive state by the full node for producing the proof information of the (i+1) th section, the time stamp of the (i+1) th section entering the exclusive state is recorded, and a timer is started to start timing; and if the timer of the full-quantity node records that the time length of the (i+1) th interval in the exclusive state is longer than the time length threshold value from the time when the (i+1) th interval is set to the exclusive state, releasing the exclusive state of the (i+1) th interval. Of course, the time length of the i+1th section in the exclusive state is counted by taking the timer as an example, in other implementations, the time length of the i+1th section in the exclusive state may also be counted by the timer, in this implementation, when the i+1th section is set to the exclusive state, the timer is started to count, if the time length of the timer is set to 2 minutes, and when the time length of the i+1th section in the exclusive state is greater than 2 minutes, the exclusive state of the i+1th section may be automatically triggered to be released.
Optionally, the process of releasing the exclusive state of the (i+1) th interval may be performed by other full nodes in the blockchain network except for the full node used for making the proof information of the (i+1) th interval; if all nodes except the full node for producing the proof information of the (i+1) th interval in the blockchain network find that the time length of the (i+1) th interval in the exclusive state is greater than a time length threshold when inquiring the state of the (i+1) th interval, the other nodes can call a withdrawal method in the block synchronization contract to cancel the exclusive state of the (i+1) th interval.
It should be noted that, in practical application, the embodiment of the present application may adopt one or more of the above two alternative manners to release the exclusive state of the (i+1) th interval; however, the embodiment of the present application does not limit the specific manner in which the exclusive state of the (i+1) -th interval is released.
S205: and (5) storing the proof information of the (i+1) th interval into the full blockchain.
And (3) after the certification information of the (i+1) th interval is produced based on the specific implementation process shown in the step (S204), the full-quantity node in the blockchain network stores the certification information of the (i+1) th interval on the full-quantity blockchain so as to realize the uplink of the certification information of the (i+1) th interval.
As described above, the blockchain network according to the embodiment of the present application may include a witness sub-network and a consensus sub-network, and then when a full-scale node for making the proof information of the i+1th interval belongs to a different sub-network, the way in which the full-scale node stores the proof information of the i+1th interval into the full-scale blockchain is different. In one implementation, when the full-scale node used to make the proof information of the (i+1) th interval is any consensus node in the consensus sub-network, the implementation of the any consensus node storing the proof information of the (i+1) th interval to the full-scale blockchain may include: and generating a new block by any consensus node based on the proving information of the (i+1) th interval, then, consensus the new block by the consensus node in the consensus sub-network, and adding the new block to the full-quantity blockchain by any consensus node after successful consensus, so that other full-quantity nodes in the consensus sub-network and/or service nodes in the witness sub-network can be synchronized to the new block from the full-quantity blockchain, and further synchronized to the proving information of the (i+1) th interval. In other implementations, when the full-scale node used to make the proof information of the (i+1) th interval is any service node in the witness sub-network, the implementation manner in which the any service node stores the proof information of the (i+1) th interval into the full-scale blockchain may include: the method comprises the steps that any service node forwards the proof information of the i+1th interval to a consensus node in the consensus sub-network through a witness sub-network and a routing node in the consensus sub-network, and the i+1th interval is successfully consensus-built by the consensus node.
In the embodiment of the application, a full-volume node in a blockchain network can deploy a block synchronization contract to divide a plurality of blocks in the full-volume blockchain into N sections and regenerate the proving information of each section, so that a subsequent lightweight node can synchronize the block heads of only a small number of blocks in the full-volume blockchain, such as the block heads of target blocks in each section, and verify the proving information of the (i+1) th section, thereby realizing the verification of the validity of the full-volume block heads in the full-volume blockchain; the efficiency of block synchronization and verification is improved, the cost required by the block synchronization of the lightweight nodes is reduced, and the burden of the lightweight nodes is lightened.
The embodiment shown in fig. 2 above mainly illustrates an implementation process of generating certification information for each section in a full-scale blockchain by using a full-scale node in a blockchain network, and a detailed query is made below with reference to fig. 6 for an implementation process of verifying certification information generated by a full-scale node by a verifier (e.g., a lightweight node). FIG. 6 is a flow chart of a block synchronization method based on a blockchain network according to an exemplary embodiment of the present application; the block synchronization scheme may be performed jointly by a full-scale node and a lightweight node in a blockchain network, and may specifically include, but is not limited to, steps S601-S606:
S601: the lightweight nodes send a block synchronization request to the full-volume nodes.
S602: the full-volume node responds to a block synchronization request sent by the lightweight node, and obtains the block head of a target block in the (i+1) th interval, the proof information of the (i+1) th interval and the common string of the verifier from the full-volume block chain.
S603: the lightweight node receives the block header of the target block in the (i+1) th interval, the proof information of the (i+1) th interval and the verifier public string, which are sent by the full-quantity node.
In steps S601-S603, the block synchronization request is used to request the full-volume nodes in the blockchain network to return the block header of the target block in the (i+1) th interval, the proof information of the (i+1) th interval, and the verifier common string. The specific implementation process of generating the proof information of the i+1st interval and the public string of the verifier by the full-quantity node can refer to the related description of the related content in the embodiment shown in fig. 2, which is not described herein. After receiving a block synchronization request sent by a lightweight node, the full-quantity node calls a deployed block synchronization contract in response to the block synchronization request to acquire the proof information and the verifier public string of the (i+1) th interval, and returns the acquired proof information and the verifier public string of the (i+1) th interval and the block header of the target block of the (i+1) th interval to the lightweight node.
It should be noted that, in the embodiment of the present application, the lightweight node is supported to obtain the block header of the target block in M intervals from the total nodes concurrently, where M is an integer, and M is e 1, n; in this case, the i+1th section is any one of the M sections, and the i section is a section adjacent to the i+1th section among the M sections. The concurrent acquisition of M intervals may refer to: the M sections need not be acquired sequentially in the order of connection of the sections in the full blockchain. Referring to fig. 7a, the lightweight node may first send a first block synchronization request to the full-volume node, where the first block synchronization request is used to request to obtain related information of the (i+1) th interval of the M intervals (such as a block header of a target block in the (i+1) th interval and proof information of the (i+1) th interval); then, the lightweight node sends a second block synchronization request to the full-volume node, wherein the second block synchronization request is used for requesting to acquire the related information of the ith interval in the M intervals. Referring to fig. 7b, the lightweight may send a block synchronization request to the full-volume node, where the block synchronization request may be used to request to acquire related information of at least two intervals of the M intervals at the same time, such as to request to acquire related information of the i-th interval and related information of the i+1th interval in one block synchronization request. The embodiment of the present application does not limit a specific implementation manner of concurrently acquiring related information of M intervals by a lightweight node, and is described herein.
Based on the block acquisition mode of the concurrent acquisition, if the lightweight node has performed acquisition of the block header of the target block and the certification information of any section (e.g., the i-th section) located before the i+1th section in the full blockchain of the full node before sending the block synchronization request for acquiring the block header of the i+1th section and the certification information of the i+1th section to the full node, it is determined that the verifier common string has been acquired together when the corresponding information of the any section is acquired, and then the full node may not repeatedly return the verifier common string to the lightweight node in response to the block synchronization request in the case that the full node detects that the verifier common string has been sent to the lightweight node. Of course, the full-volume node may return the verifier common string each time a block synchronization request sent by the lightweight node is received.
S604: the lightweight node obtains a chunk header hash of the target chunk in the ith interval on the full blockchain.
As described above, the block header hash of the block is generated based on the parameters included in the block header of the previous block of the block, so, in order to calculate the block header hash of the first block in the i+1th interval, the embodiment of the present application needs to acquire the block header hash of the target block (i.e. the last block) in the i+1th interval, so as to implement the calculation of 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 i+1th interval and the parameters included in the block header of the first block in the i+1th interval, thereby implementing the verification of the proof information of the i+1th interval.
The implementation manner of the lightweight node to obtain the block header hash of the target block in the ith interval on the full blockchain may include: if the lightweight node has obtained the block header hash of the target block in the i-th section from the full blockchain before verifying the certification information of the i+1th section, then the lightweight node may directly obtain the block header of the target block in the i-th section from the storage space in the lightweight node in this case. Alternatively, the lightweight node may send a request to the full-size node to obtain the chunk header hash of the target chunk in the i-th section, i.e., the lightweight node may obtain the chunk header hash of the target chunk in the i-th section from the full-size blockchain of the full-size node. The embodiment of the present application does not limit the specific manner of obtaining the block header hash of the target block in the i-th interval.
S605: the lightweight node verifies the certification information of the i+1th section based on the block header of the target block pair in the i-th section and the block header of the target block in the i+1th section.
Considering that any block in the legal full-quantity block chain is hashed by the block head containing the previous block, when verifying the proving information of the interval, the lightweight node adopts a serial verification mode, namely, when the proving information of the ith interval is successfully verified, the proving information of the (i+1) th interval is continuously verified; if the lightweight node fails to verify the certification information of the ith section, which means that one or more blocks included in the ith section are illegal, it does not make sense to continue verifying the certification information of the (i+1) th section, and the verification of the certification information of sections subsequent to the ith section is stopped.
An exemplary schematic diagram of concurrently acquiring the certification information of each section and serially verifying the certification information of each section may refer to fig. 8, and as shown in fig. 8, the process of serially verifying the certification information of each block by the lightweight node may generally include: firstly, synchronizing the block heads of the created blocks on the full block chain from the full node; when i=1, verifying the proof information of the ith interval according to the block head of the created block and the block head of the target block in the ith interval; if the verification of the proof information of the ith section is successful, storing the block header of the target block in the ith section into a storage space, continuously acquiring the block header hash of the first reference block in the ith section from the proof information of the ith section, and continuously verifying the proof information of the (i+1) th section; and by analogy, at least verifying the proving information of N intervals in the full blockchain is successful, or stopping the verifying operation until the verifying result of proving information of a certain interval is failure. It will be appreciated based on the description of fig. 8 that the generated block in the full blockchain may belong to a single section, and that the lightweight node defaults that the block header of the generated block is legal during serial verification.
As can be seen from the related description of the embodiment shown in fig. 2, the proof information of the (i+1) th interval includes: proving the output information of the character string and the zero knowledge proving circuit; the proving character string is generated by a calculation process of calculating the output information by a zero knowledge proving circuit based on the proving person public string by the full quantity node; the generation of the proving string represents: the full-quantity node proving that the circuit has executed a calculation process based on zero knowledge; the prover public string is the key used by the prover; the prover includes a full volume of nodes. Wherein the output information of the zero knowledge proof circuit comprises: the block header hash of the target block in the i-th section calculated by the zero knowledge proof circuit is used, the block header hash of each block in the i+1-th section calculated by the zero knowledge proof circuit is used, and the circuit check result is obtained. The circuit inspection result is used for indicating: and (3) whether the block head hash obtained by the calculation of the zero knowledge proof circuit is matched with the block head hash of the corresponding block in the full block chain or not. Then in the specific implementation process, the verifying, by the lightweight node, 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 hash of the target block in the i+1th interval may include: and verifying the proof character string contained in the proof information of the (i+1) th interval and verifying the output information of the zero knowledge proof circuit.
The following describes a specific implementation procedure for verifying 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 hash of the target block in the i+1th interval, where:
1) And obtaining a common string of the verifier from the full blockchain, and verifying the proving character string in the proving information of the (i+1) th interval by adopting the common string to obtain a first verification result. Wherein the proof character string is generated by a calculation process of obtaining output information by a prover (i.e. the full-scale node) through calculation of the zero-knowledge proof circuit by using the prover character string, and when the first verification result is that verification is successful, it can be determined that the full-scale node has indeed completed the calculation process of the zero-knowledge proof circuit, where the calculation process may include: a process of calculating a block header hash of a target block within an i-th section using a zero-knowledge proof circuit, a process of calculating a block header hash of each block in the i+1th section using a zero-knowledge proof circuit, and a process of generating a circuit inspection result.
2) The value of the circuit inspection result is read from the output information of the zero knowledge proof circuit included in the proof information of the i+1th section. As described above, the circuit check result of the zero knowledge proof circuit output may be used to indicate: the zero knowledge proof circuit is adopted to calculate whether the obtained block head hash is matched with the block head hash of the corresponding block in the full block chain; if the value of the circuit check result is a preset value, the circuit check result at this time is used for indicating: the block header hash calculated by the zero knowledge proof circuit is matched with the block header hash of the corresponding block in the full block chain, so that the full node judges that the block in the full block chain is legal. Otherwise, if the value of the circuit inspection result is not the preset value, the circuit inspection result at this time is used for indicating: and the block head hash obtained by calculation by adopting the zero knowledge proof circuit is not matched with the block head hash of the corresponding block in the full-quantity block chain, so that the full-quantity node judges that illegal blocks exist in the full-quantity block chain.
3) And verifying the hash of the block head contained in the output information of the zero knowledge proof circuit in the proof information of the (i+1) th interval according to the block head of the target block in the (i) th interval, so as to obtain a second verification result. In a specific implementation, the second verification result includes a first comparison result and a second comparison result; the first comparison result is obtained by verifying the block header of the target block in the ith interval, and the second comparison result is obtained by verifying the block header of the target block in the (i+1) th interval. The following is a specific implementation procedure for obtaining the first comparison result and the second comparison result, respectively, where:
(1) and verifying the block head of the target block in the ith interval to obtain a first comparison result. Specifically, since the lightweight node verifies the certification information of each section by adopting a serial verification manner, when the lightweight node triggers verification of the certification information of the (i+1) th section, it can be determined that the certification information of the (i) th section is verified successfully, and the lightweight node can obtain the block header hash of the first reference block in the (i) th section from the certification information of the (i) th section, wherein the first reference block is a block with a block height smaller than that of the target block in the (i) th section by 1. Then, the block header hash of the target block in the ith section is calculated according to the block header hash of the first reference block and parameters (such as time stamp, block height, etc.) contained in the block header of the target block in the ith section. And finally, comparing the calculated block head hash of the target block in the ith section with the output information of the zero knowledge proof circuit in the proof information of the ith section according to the block head hash of the first reference block, and obtaining a first comparison result. When the first comparison result is that the comparison is successful, the block header of the target block in the ith interval is legal, and the block header of the target block in the (i+1) th interval is continuously verified. Otherwise, when the first comparison result is that the comparison fails, the block header of the target block in the ith interval is illegal, and the subsequent verification operation is stopped.
(2) And verifying the block head of the target block in the (i+1) th interval to obtain a second comparison result. On the premise that the block head of the target block in the ith interval is determined to be a legal block head, the block head 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 having a block height in the i+1th section that is 1 smaller than a block height of the target block in the i+1th section. Then, the block header hash of the target block in the i+1th section is calculated from the block header hash of the second reference block and the block header hash of the target block in the i+1th section. And finally, comparing the calculated block head hash of the target block in the (i+1) th section with the output information of the zero knowledge proof circuit in the proof information of the (i+1) th section according to the block head hash of the second reference block, and obtaining a second comparison result. And when the second comparison result is that the comparison is successful, the block head 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 is continued. Otherwise, when the second comparison result is that the comparison fails, the block header of the target block in the (i+1) th interval is illegal, and the subsequent verification operation is stopped.
And generating a second verification result based on the first comparison result and the second comparison result. If the first comparison result is successful and the second comparison result is successful, determining that the second verification result is successful; if any one of the first comparison result and the second comparison result is the comparison failure, determining the second verification result as the verification failure. Wherein: when the second verification result is that verification is successful, the calculated block header hash of the target block in the ith interval is matched with 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 calculated block header hash of the target block in the (i+1) th interval is matched 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 this case, it is determined that the block heads of all blocks after the target block linked in the i-th section and before the target block linked in the i+1th section are legal, and verification of the certification information of the i+2th section is continuously performed. Otherwise, when the second verification result is that verification fails, the calculated block header hash of the target block in the ith interval is not matched with 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 calculated block header hash of the target block in the (i+1) th interval is not matched 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 this case, it is determined that the block header, which is linked to the target block in the i-th section and in which one or more blocks exist in all blocks preceding the target block in the i+1th section, is illegal, and verification of the certification information for the subsequent section is stopped.
S606: if the proof information of the (i+1) th interval is verified successfully, the block head of the target block in the (i+1) th interval is stored into the storage space.
In specific implementation, when the verification of the proof information of the (i+1) th interval is determined to be successful, the embodiment of the application supports the storage of the block head of the target block in the (i) th interval into the storage space; the storage space may refer to: space for storing the block header of the target block within each section that has been verified to be successful. The target blocks in each verified block in the storage space can be stored according to a storage rule; wherein the storage rules may include, but are not limited to: sequential storage, random storage, etc. The sequential storage means that the block heads of the target blocks in each section which are verified to be successful are stored according to the connection sequence between the sections; an exemplary block header diagram for sequentially storing blocks is shown in fig. 9. The random storage may be to randomly store the block header of the target block in each section that has been verified successfully into space, without regard to the storage order of each block header.
In the embodiment of the present application, the lightweight nodes in the blockchain network can synchronize the blockheads of a small number of blocks from the full blockchain of the full nodes, such as the blockheads of the synchronous creation blocks and the blockheads of the target blocks in each interval, the validity of the full block head in the full block chain can be verified according to a small number of block heads, the efficiency of block synchronization and verification is improved, the existence of a transaction can be queried immediately even under the condition of not synchronizing the transaction blocks, the expenditure required by block synchronization is reduced, and the burden of light-weight nodes is lightened.
The embodiment shown in fig. 2 above mainly illustrates the implementation process of generating the certification information for each section in the full-scale blockchain by the full-scale nodes in the blockchain network, and the embodiment shown in fig. 6 mainly illustrates the implementation process of verifying the certification information generated by the full-scale nodes by a verifier (such as a lightweight node). An implementation procedure of executing a service function (such as executing a service function of inquiring about the existence of a transaction) by a verifier is given below in conjunction with fig. 10; FIG. 10 is a flow chart of a block synchronization method based on a blockchain network according to an exemplary embodiment of the present application; the block synchronization scheme may be performed jointly by a full-scale node and a lightweight node in a blockchain network, and may specifically include, but is not limited to, steps S1001-S1011:
s1001: the full-volume node generates certification information for each interval in the full-volume blockchain network and falls on the certification information of each interval.
It should be noted that, for the specific implementation process of the certification information generated by the full-volume node for each section in the full-volume blockchain, reference may be made to the related description of the specific implementation process shown in steps S201 to S205 in the embodiment shown in fig. 2, which is not repeated herein.
S1002: the full-quantity node receives a block synchronization request sent by the lightweight node.
S1003: the full-quantity node responds to the block synchronization request to acquire the block head of the target block in the (i+1) th interval, the proof information of the (i+1) th interval and the common string of the verifier.
S1004: the full-quantity node returns the block header of the target block in the (i+1) th section, the proof information of the (i+1) th section, and the verifier common string to the lightweight node.
S1005: the lightweight node verifies the proof information of the (i+1) th section based on the received block header of the target block in the (i+1) th section, the proof information of the (i+1) th section and the common string of the verifier, and stores the block header of the target block in the (i+1) th section after the verification is successful.
It should be noted that, the specific implementation process shown in steps S1002-S1005 may refer to the related description of the specific implementation process shown in steps S601-S606 in the embodiment shown in fig. 6, which is not described herein. In addition, the procedure shown in steps S1002 to S1005 is described taking the example that the lightweight node verifies the proof information of the (i+1) th section; in practical application, the lightweight nodes sequentially verify the proving information of each section in a serial verification mode; the specific implementation process of verifying the certification information of each interval by the lightweight node can be referred to as related description in the embodiment shown in fig. 6.
S1006: the lightweight node receives transaction inquiry information sent by the client.
S1007: the lightweight nodes generate transaction inquiry requests based on the transaction inquiry information and send the transaction inquiry requests to the full-scale nodes.
In steps S1006-S1007, as described above, lightweight nodes in the blockchain network may assume some traffic functions; for example, in an invoice transaction uplink business scenario, a lightweight node may assume business functions that query for the existence of a transaction, such as querying whether a target transaction exists in a full blockchain. In a specific implementation, a client having a query requirement for the existence of a target transaction may send transaction query information to a lightweight node, where the transaction query information includes a transaction hash of the target transaction, a merck path of the target transaction, and a block height of a block to which the target transaction belongs; when the lightweight node receives the transaction inquiry information sent by the client, determining that a transaction inquiry event aiming at the target transaction is generated, namely the transaction inquiry event is generated when the lightweight node acquires the transaction inquiry information sent by the client, and then the lightweight node can respond to the transaction inquiry event aiming at the target transaction to send a transaction inquiry request to the full-quantity node.
S1008: and the full-quantity node receives a transaction inquiry request sent by the lightweight node, and responds to the transaction inquiry request to acquire the block header of the block to which the target transaction belongs.
S1009: and the full-quantity node returns the block head of the block to which the target transaction belongs and the proof information of the (i+1) th block corresponding to the block to which the target transaction belongs to the lightweight node.
In steps S1008-S1009, the transaction inquiry request sent by the lightweight node includes the block height corresponding to the target transaction, so that after the full-quantity node receives the transaction inquiry request, the block to which the target transaction belongs is determined 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 inquiry request is 7, the sixth block linked to the created block in the full blockchain is determined as the block to which the target transaction belongs. Further, after determining the block to which the target transaction belongs, the full-volume node may invoke a block synchronization contract to obtain the proof information of the (i+1) th interval corresponding to the block to which the target transaction belongs. And then, returning the proof information of the (i+1) th interval corresponding to the block to which the target transaction belongs and the block header of the block to which the target transaction belongs to the lightweight node.
S1010: and the lightweight node inquires whether the target transaction belongs to the block or not according to the block head of the block to which the target transaction belongs and the proof information of the (i+1) th block corresponding to the block to which the target transaction belongs, and obtains an inquiry result.
S1011: the lightweight nodes output query results.
In steps S1010-S1011, it is noted that in the embodiment shown in fig. 6, the lightweight node has successfully verified the proof information of the i+1st interval, i.e. the lightweight node has successfully verified before querying that the block existing in the i+1st interval contains the target transaction: the block header of the target block in the (i+1) th interval, the block header of all blocks in the (i+1) th interval in the full blockchain are legal (or referred to as valid blocks); in the transaction inquiry verification, the lightweight node only needs to determine that the block to which the target transaction belongs is any one of the (i+1) th blocks, and the block to which the target transaction belongs contains the target transaction.
Based on the above description, the following description will briefly explain the implementation process of the lightweight node to query whether there is a target transaction in the block to which the target transaction belongs; 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 is a block with a block height 1 smaller than the block height of the block to which the target transaction belongs in the i+1th interval. 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, specifically, 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 parameters contained in the block header of the block to which the target transaction belongs. Secondly, 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+1) th interval, which means that the block to which the target transaction belongs is one of the effective blocks in the (i+1) th interval, generating a merck root based on the transaction hash of the target transaction and the merck path of the target transaction; then, if the generated merck root is detected to exist in the block head of the block to which the target transaction belongs, and the generated merck root indicates that the target transaction exists in the block to which the target transaction belongs, a query result is generated, and the query result is used for indicating that the target transaction exists in the block to which the target transaction belongs. Finally, when the lightweight node calculates the query result, the lightweight node can return the query result to the client.
It should be noted that, the foregoing describes the business logic for querying the existence of the transaction by taking the client and the lightweight node as different devices as examples; however, in practical applications, the client and the lightweight node may be the same device, for example, the lightweight node is a client that accesses to the blockchain network, and in the embodiment of the present application, whether the client and the lightweight node are the same device is not limited. In addition, when the embodiment of the application is applied to a specific product or technology, for example, when the lightweight node synchronizes the target transaction affiliated block including the target transaction from the full-quantity nodes, the permission or agreement of the target object for generating the target transaction needs to be obtained; and the collection, use and processing of the relevant data is required to comply with relevant legal regulations and standards of the relevant country and region, such as the acquisition and uplink of the target transaction is required to comply with relevant legal regulations and standards of the relevant country and region.
Compared with the block synchronization method of the existing main stream, the block synchronization method based on the block chain network has obvious advantages, and the block synchronization method provided by the application is compared and given according to the block synchronization method of the existing main stream. In the existing mainstream block synchronization method, a service node newly added into a blockchain network needs to start from the created blocks of the full blockchain and synchronize the block head of each block in sequence, so that the block head of the synchronized block can be confirmed to be effective; this way of synchronizing the block headers of all the blocks reduces the block synchronization efficiency, and the block synchronization overhead is large and is detrimental for the service node to perform the service function of querying the existence of the transaction, for example: before the height of the blocks synchronized on the service node does not catch up with the full-volume blockchain, if the height of the blocks of the full-volume blockchain is H, when the service node is synchronized to the blocks with the height of H, the service node receives a query request and needs to query whether one transaction in the blocks with the height of h+n is on the chain or not; in this case, the service node cannot find the transaction because the service node has not synchronized to the tile with the tile height h+n. However, the lightweight node in the blockchain network provided by the embodiment of the application can only synchronize the blockheads of a small number of blocks from the full blockchain of the full blockchain, such as the blockheads of the synchronous generation blocks and the blockheads of the target blocks in each interval, so that the validity of the full blockhead in the full blockchain can be verified according to the small number of blockheads, the efficiency of block synchronization and verification is improved, even under the condition of unsynchronized transaction blocks, the existence of the transaction can be queried in real time, the cost required by block synchronization is reduced, and the burden of the lightweight node is lightened.
The foregoing details of the method of the embodiments of the present application are set forth in order to provide a better understanding of the method of the embodiments of the present application, and accordingly, an apparatus of the embodiments of the present application is provided below.
FIG. 11 is a block diagram illustrating a block synchronization device based on a blockchain network, which may be a computer program (including program code) running in a lightweight node, according to an exemplary embodiment of the present application; the blockchain network-based blocksynchronization device may be used to perform some or all of the steps of the method embodiments shown in fig. 6 and 10; wherein the blockchain network includes full-scale nodes and lightweight nodes; the full-quantity node stores a full-quantity blockchain, wherein the full-quantity blockchain comprises N sections, N is an integer larger than 1, each section comprises one or more blocks connected in sequence, each section corresponds to one piece of proving information, and the proving information is used for proving the correctness of the blocks in the corresponding section; the lightweight nodes store block heads of partial blocks in the full-volume block chain; the block synchronization device is a lightweight node, and comprises the following units:
an obtaining unit 1101, configured to obtain a block header of a target block in an ith interval on the full blockchain, where proof information of the ith interval is verified; i=1, 2 … N-1;
A processing unit 1102, configured to synchronize, from a full-volume node, a block header of a target block in an i+1th interval on a full-volume blockchain, and synchronize certification information of the i+1th interval;
the processing unit 1102 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;
the processing unit 1102 is further configured to store the block header of the target block in the i+1th interval to the storage space if the verification of the proof information of the i+1th interval is successful.
In one implementation, the full blockchain also includes an creative block thereon; the processing unit 1102 is further configured to:
synchronizing the block heads of the created blocks on the full-volume block chain from the full-volume nodes;
when i=1, verifying the proof information of the ith interval according to the block head of the created block and the block head of the target block in the ith interval;
if the verification of the proof information of the ith interval is successful, the block head of the target block in the ith interval is stored into the storage space.
In one implementation, the obtaining unit 1101 is specifically configured to, when obtaining the block header of the target block in the ith interval on the full blockchain:
The method comprises the steps of concurrently obtaining block heads of target blocks in M sections from a total number of nodes, wherein M is an integer, M is E [1, N ], and an ith section is any one of the M sections; or alternatively, the process may be performed,
the block header of the target block in the ith section is obtained from the storage space in the lightweight node.
In one implementation, the certification information includes a certification string and output information of the zero knowledge certification circuit; the proving character string is generated by a calculation process of calculating the output information by a zero knowledge proving circuit based on the proving person public string by the full quantity node; the generation of the proving string represents: the full-quantity node proving that the circuit has executed a calculation process based on zero knowledge; the prover public string is the key used by the prover; the prover includes a full volume node;
wherein the output information of the zero knowledge proof circuit comprises: the zero knowledge proof circuit is adopted to calculate the block header hash of the target block in the ith interval, the zero knowledge proof circuit is adopted to calculate the block header hash of each block in the (i+1) th interval, and the circuit check result is adopted;
the circuit inspection result is used for indicating: and (3) whether the block head hash obtained by the calculation of the zero knowledge proof circuit is matched with the block head hash of the corresponding block in the full block chain or not.
In one implementation, the full blockchain has stored therein a verifier common string; the verifier-public string is the key used by the verifier; the verifier includes a lightweight node; the processing unit 1102 is configured to, when verifying 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, specifically be:
obtaining a common string of a verifier from the full blockchain, and verifying a proving character string in proving information of the (i+1) th interval by adopting the common string of the verifier to obtain a first verification result;
reading the value of the circuit inspection result from the output information of the zero knowledge proof circuit contained in the proof information of the (i+1) th interval; the method comprises the steps of,
verifying the hash of the block head contained in the output information of the zero knowledge proof circuit in the proof information of the (i+1) th interval according to the block head of the target block in the (i) th interval to obtain a second verification result;
if the first verification result is verification success, the value of the circuit checking result is a preset value, and the second verification result is verification success, determining that the verification result corresponding to the (i+1) th interval is verification success;
when the value of the circuit check result is a preset value, the circuit check result is used for indicating: the block header hash calculated by the zero knowledge proof circuit is matched with the block header hash of the corresponding block in the full block chain.
In one implementation manner, the processing unit 1102 is configured to verify, according to a block header of a target block in the ith interval, a block header hash included in output information of the zero knowledge proof circuit in proof information of the (i+1) th interval, where the second verification result is obtained, specifically configured to:
acquiring a block header hash of a first reference block in an ith interval from the proof information of the ith interval; the first reference block is a block having a block height 1 smaller than a block height of the target block in the i-th section;
calculating the block head hash of the target block in the ith interval according to the block head hash of the first reference block;
comparing the calculated block header hash of the target block in the ith interval with the output information of the zero knowledge proof circuit in the proof information of the ith interval, and obtaining a first comparison result;
obtaining the block header hash of the second reference block in the (i+1) th interval from the proof information of the (i+1) th interval; the second reference block is a block having a block height in the i+1th section that is 1 smaller than the block height of the target block in the i+1th section;
Calculating the block head hash of the target block in the (i+1) th interval according to the block head hash of the second reference block;
comparing the calculated block head hash of the target block in the (i+1) th interval with the output information of the zero knowledge proof circuit in the proof information of the (i+1) th interval, and comparing the block head hash of the target block in the (i) th interval with the output information of the zero knowledge proof circuit to obtain a second comparison result;
if the first comparison result is successful and the second comparison result is successful, determining that the second verification result is successful.
In one implementation, the processing unit 1102 is further configured to:
responding to a transaction inquiry event aiming at the target transaction, and sending a transaction inquiry request to the full-quantity node, wherein the transaction inquiry request comprises the block height corresponding to the target transaction, so that the full-quantity node determines the block to which the target transaction belongs based on the block height corresponding to the target transaction;
receiving the block head 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, wherein the block head of the block to which the target transaction belongs is returned by the full node in response to the transaction inquiry request;
inquiring whether the target transaction exists in the block to which the target transaction belongs or not based on the block head of the block to which the target transaction belongs and the proof information of the (i+1) th interval, and obtaining an inquiry result;
And outputting the query result.
In one implementation, the transaction inquiry event is an event generated when transaction inquiry information sent by the client is acquired; the transaction inquiry information comprises a transaction hash of the target transaction and a merck path of the target transaction; the processing unit 1102 is configured to query whether a target transaction exists in a block to which the target transaction belongs based on a block header of the block to which the target transaction belongs and proof information of an i+1th interval, and when obtaining a query result, is specifically configured to:
obtaining the block head hash of the third reference block from the output information of the zero knowledge proof circuit in the proof information of the (i+1) th interval, and calculating the block head hash of the block to which the target transaction belongs according to the block head hash of the third reference block; the third reference block is a block with a block height 1 smaller than the block height of the block to which the target transaction belongs in the (i+1) th interval;
if the calculated block head hash of the block to which the target transaction belongs is the same as the block head 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+1) th interval, generating a merck root based on the transaction hash of the target transaction and the merck path of the target transaction;
If the generated merck root exists in the block header of the block to which the target transaction belongs, a query result is generated, wherein the query result is used for indicating that the target transaction exists in the block to which the target transaction belongs.
In one implementation, the target block refers to a block with the largest block height within the interval.
According to one embodiment of the present application, each unit in the block synchronization device based on the blockchain network shown in fig. 11 may be separately or completely combined into one or several additional units, or some unit(s) thereof may be further split into a plurality of units with smaller functions to form the same operation, which does not affect the implementation of the technical effects of the embodiments of the present application. The above units are divided based on logic functions, and in practical applications, the functions of one unit may be implemented by a plurality of units, or the functions of a plurality of units may be implemented by one unit. In other embodiments of the present application, the blockchain network-based blocksynchronization device may also include other units, and in practical applications, these functions may also be implemented with assistance from other units, and may be implemented by a plurality of units in cooperation. According to another embodiment of the present application, the blockchain network-based blocksynchronization apparatus as shown in fig. 11 may be constructed by running a computer program (including program code) capable of executing the steps involved in the respective methods as shown in fig. 6 and 10 on a general-purpose computing device such as a computer including a Central Processing Unit (CPU), a random access storage medium (RAM), a read only storage medium (ROM), etc., processing elements and storage elements, and implementing the blockchain network-based blocksynchronization method of the embodiments of the present application. The computer program may be recorded on, for example, a computer-readable recording medium, and loaded into and run in the above-described computing device through the computer-readable recording medium.
In the embodiment of the application, the blockchain network comprises a full-quantity node and a lightweight node; the full-volume node stores therein a full-volume blockchain (e.g., a blockchain including block heads of all blocks), and a plurality of blocks sequentially connected in the full-volume blockchain are divided into N sections, where N is an integer greater than 1. The processing unit 1102 may synchronize only the block header of the target block and the corresponding certification information within the (i+1) th interval on the full blockchain from the full node; then, the lightweight node verifies 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; 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 scheme, the block heads of a small number of blocks can be synchronized from the full-volume block chain of the full-volume node, for example, the block heads of the synchronous generation blocks and the block heads of the target blocks in each interval can be verified according to the small number of block heads, so that the efficiency of block synchronization and verification is improved, the cost required by the block synchronization of the light-weight node is reduced, and the load of the light-weight node is lightened.
FIG. 12 is a block diagram illustrating a block synchronization device based on a blockchain network, which may be a computer program (including program code) running in a full-scale node, according to an exemplary embodiment of the present application; the blockchain network-based blocksynchronization device may be used to perform some or all of the steps of the method embodiments shown in fig. 2 and 10; wherein the blockchain network includes full-scale nodes and lightweight nodes; the full-quantity node stores a full-quantity blockchain, wherein the full-quantity blockchain comprises N sections, N is an integer larger than 1, each section comprises one or more blocks connected in sequence, each section corresponds to one piece of proving information, and the proving information is used for proving the correctness of the blocks in the corresponding section; the lightweight nodes store block heads of partial blocks in the full-volume block chain; the block synchronization device is a full-scale node, and comprises the following units:
a receiving unit 1201, configured to receive a block synchronization request sent by a lightweight node;
a processing unit 1202, configured to return, in response to a block synchronization request, a block header of a target block in an i+1th interval and certification information of the i+1th interval on the full-volume blockchain to the lightweight node, so that the lightweight node verifies the certification 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; after the proof information of the (i+1) th interval is successfully verified, the block head of the target block in the (i+1) th interval is stored into a storage space of the lightweight node by the lightweight node; i=1, 2 … N-1.
In one implementation, the processing unit 1202 is further configured to:
acquiring a zero knowledge proof circuit generated based on a proposition to be proved, wherein the proposition to be proved is used for indicating to verify the correctness of the block heads of partial blocks in the full block chain;
deploying the block synchronization contract, and dividing a plurality of blocks connected in sequence in the full block chain into N intervals in the process of deploying the block synchronization contract;
invoking a block synchronization contract to set the state of the (i+1) th interval to be an exclusive state, and extracting the block header hash of each block in the (i+1) th interval and the block header hash of a target block in the (i) th interval from the full blockchain; the target block in the ith section is the block with the largest block height in the ith section;
according to the zero knowledge proving circuit, verifying the block head hash of each block in the (i+1) th interval and the block head hash of the target block in the (i) th interval to generate proving information of the (i+1) th interval;
and (5) storing the proof information of the (i+1) th interval into the full blockchain.
In one implementation, the proof information for the (i+1) th interval includes: zero knowledge proof circuit output information; the processing unit 1202 is configured to perform verification processing on the chunk header hash of each chunk in the i+th interval and the chunk header hash of the target chunk in the i+th interval according to the zero knowledge proof circuit, and is specifically configured to, when generating proof information of the i+1 th interval:
Obtaining the block head hash of a first reference block in the ith interval from the full block chain, and calculating the block head hash of a target block in the ith interval according to the block head hash of the first reference block; the first reference block is a block having a block height 1 smaller than a block height of the target block in the i-th section;
for each block in the (i+1) th interval, calculating the block header hash of each block by adopting the block header hash of the previous block to obtain the block header hash of each block in the (i+1) th interval;
verifying the calculated block header hash of the target block in the ith interval and the calculated block header hash of each block in the (i+1) th interval to generate a circuit checking result;
wherein the output information of the zero knowledge proof circuit comprises: the block header hash of the target block in the i-th section calculated by the zero knowledge proof circuit is used, the block header hash of each block in the i+1-th section calculated by the zero knowledge proof circuit is used, and the circuit check result is obtained.
In one implementation, the processing unit 1202 is configured to 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, and when generating the circuit check result, specifically is configured to:
Comparing the block header hash of the target block in the i-th section calculated by the zero knowledge proof circuit with the block header hash of the target block in the i-th section extracted from the full blockchain;
and comparing 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;
if the comparison results are successful, generating a circuit check result, wherein the value of the circuit check result is a preset value for indicating: the block header hash calculated by the zero knowledge proof circuit is matched with the block header hash of the corresponding block in the full block chain.
In one implementation, the proof information corresponding to the (i+1) th interval further includes: a certification string; the processing unit 1202 is further configured to:
acquiring 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, which includes a full number of nodes; the verifier-public string is a key used by a verifier, which comprises lightweight nodes;
Storing the verifier common string to a full blockchain; the method comprises the steps of,
based on the prover public string, a proving character string generated in the calculation process of the output information is obtained by the calculation of the zero knowledge proving circuit; the generation of the proving string represents: the full-scale nodes prove that the circuit has performed a calculation process based on zero knowledge.
In one implementation, the processing unit 1202 is further configured to:
if the proof information of the (i+1) th interval is detected to be generated, releasing the exclusive state of the (i+1) th interval; or alternatively, the process may be performed,
and if the time length of the (i+1) th section in the exclusive state is greater than the time length threshold value from the time when the (i+1) th section is set in the exclusive state, releasing the exclusive state of the (i+1) th section.
According to one embodiment of the present application, each unit in the block synchronization device based on the blockchain network shown in fig. 11 may be separately or completely combined into one or several additional units, or some unit(s) thereof may be further split into a plurality of units with smaller functions to form the same operation, which does not affect the implementation of the technical effects of the embodiments of the present application. The above units are divided based on logic functions, and in practical applications, the functions of one unit may be implemented by a plurality of units, or the functions of a plurality of units may be implemented by one unit. In other embodiments of the present application, the blockchain network-based blocksynchronization device may also include other units, and in practical applications, these functions may also be implemented with assistance from other units, and may be implemented by a plurality of units in cooperation. According to another embodiment of the present application, the blockchain network-based blocksynchronization apparatus as shown in fig. 12 may be constructed by running a computer program (including program code) capable of executing the steps involved in the respective methods as shown in fig. 2 and 10 on a general-purpose computing device such as a computer including a Central Processing Unit (CPU), a random access storage medium (RAM), a read only storage medium (ROM), etc., processing elements and storage elements, and implementing the blockchain network-based blocksynchronization method of the embodiments of the present application. The computer program may be recorded on, for example, a computer-readable recording medium, and loaded into and run in the above-described computing device through the computer-readable recording medium.
In this embodiment of the present application, the processing unit 1202 may deploy a block synchronization contract to divide a plurality of blocks in the full-size blockchain into N intervals, and regenerate the certification information of each interval, so that the subsequent lightweight node may synchronize only the block heads of a small number of blocks from the full-size blockchain, for example, the block heads of the target blocks in each interval, and verify the certification information of the i+1th interval, so as to implement verification of the validity of the full-size block heads in the full-size blockchain; the efficiency of block synchronization and verification is improved, the cost required by the block synchronization of the lightweight nodes is reduced, and the burden of the lightweight nodes is lightened.
Fig. 13 is a schematic structural diagram of a blockchain node device according to an exemplary embodiment of the present application. Referring to fig. 13, the block link point apparatus includes a processor 1301, a communication interface 1302, and a computer readable storage medium 1303. Wherein the processor 1301, the communication interface 1302, and the computer readable storage medium 1303 may be connected by a bus or other means. Wherein the communication interface 1302 is for receiving and transmitting data. The computer readable storage medium 1303 may be stored in a memory of the block link point device, the computer readable storage medium 1303 for storing a computer program including program instructions, and the processor 1301 for executing the program instructions stored by the computer readable storage medium 1303. Processor 1301 (or CPU (Central Processing Unit, central processing unit)) is a computing core and a control core of a blockchain node device adapted to implement one or more instructions, in particular adapted to load and execute one or more instructions to implement a corresponding method flow or a corresponding function.
The embodiment of the application also provides a computer readable storage medium (Memory), wherein the computer readable storage medium is a Memory device in the block link point device and is used for storing programs and data. It will be appreciated that the computer readable storage medium herein may include both built-in storage media in the blockchain node device and extended storage media supported by the blockchain node device. The computer readable storage medium provides a memory space that stores a processing system of the block link point device. Also stored in this memory space are one or more instructions, which may be one or more computer programs (including program code), adapted to be loaded and executed by processor 1301. Note that the computer readable storage medium can be either a high-speed RAM memory or a non-volatile memory (non-volatile memory), such as at least one magnetic disk memory; alternatively, it may be at least one computer-readable storage medium located remotely from the aforementioned processor.
In one embodiment, the computer-readable storage medium has one or more instructions stored therein; one or more instructions stored in a computer-readable storage medium are loaded and executed by processor 1301 to implement the corresponding steps in the blockchain network-based blocksynchronization method embodiment described above. In a specific implementation, the blockchain network comprises a full-scale node and a lightweight node; the full-quantity node stores a full-quantity blockchain, wherein the full-quantity blockchain comprises N sections, N is an integer larger than 1, each section comprises one or more blocks connected in sequence, each section corresponds to one piece of proving information, and the proving information is used for proving the correctness of the blocks in the corresponding section; the lightweight nodes store block heads of partial blocks in the full-volume block chain; the blockchain node device is a lightweight node, and one or more instructions in a computer readable storage medium are loaded by the processor 1301 and perform the steps of:
Acquiring the block head of a target block in the ith interval on the full block chain, wherein the proof information of the ith interval is verified successfully; i=1, 2 … N-1;
synchronizing the block head of the target block in the (i+1) th interval on the full block chain from the full node, and synchronizing the certification information of the (i+1) th interval;
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;
if the proof information of the (i+1) th interval is verified successfully, the block head of the target block in the (i+1) th interval is stored into the storage space.
In one implementation, the full blockchain also includes an creative block thereon; one or more instructions in the computer-readable storage medium are loaded by processor 1301 and further perform the steps of:
synchronizing the block heads of the created blocks on the full-volume block chain from the full-volume nodes;
when i=1, verifying the proof information of the ith interval according to the block head of the created block and the block head of the target block in the ith interval;
if the verification of the proof information of the ith interval is successful, the block head of the target block in the ith interval is stored into the storage space.
In one implementation, one or more instructions in a computer-readable storage medium are loaded by processor 1301 and when executed perform the steps of:
the method comprises the steps of concurrently obtaining block heads of target blocks in M sections from a total number of nodes, wherein M is an integer, M is E [1, N ], and an ith section is any one of the M sections; or alternatively, the process may be performed,
the block header of the target block in the ith section is obtained from the storage space in the lightweight node.
In one implementation, the certification information includes a certification string and output information of the zero knowledge certification circuit; the proving character string is generated by a calculation process of calculating the output information by a zero knowledge proving circuit based on the proving person public string by the full quantity node; the generation of the proving string represents: the full-quantity node proving that the circuit has executed a calculation process based on zero knowledge; the prover public string is the key used by the prover; the prover includes a full volume node;
wherein the output information of the zero knowledge proof circuit comprises: the zero knowledge proof circuit is adopted to calculate the block header hash of the target block in the ith interval, the zero knowledge proof circuit is adopted to calculate the block header hash of each block in the (i+1) th interval, and the circuit check result is adopted;
The circuit inspection result is used for indicating: and (3) whether the block head hash obtained by the calculation of the zero knowledge proof circuit is matched with the block head hash of the corresponding block in the full block chain or not.
In one implementation, the full blockchain has stored therein a verifier common string; the verifier-public string is the key used by the verifier; the verifier includes a lightweight node; the one or more instructions in the computer-readable storage medium are loaded by the processor 1301 and when executing verification of the proof information of the i+1th section based on the block header of the target block in the i-th section and the block header of the target block in the i+1th section, specifically perform the following steps:
obtaining a common string of a verifier from the full blockchain, and verifying a proving character string in proving information of the (i+1) th interval by adopting the common string of the verifier to obtain a first verification result;
reading the value of the circuit inspection result from the output information of the zero knowledge proof circuit contained in the proof information of the (i+1) th interval; the method comprises the steps of,
verifying the hash of the block head contained in the output information of the zero knowledge proof circuit in the proof information of the (i+1) th interval according to the block head of the target block in the (i) th interval to obtain a second verification result;
If the first verification result is verification success, the value of the circuit checking result is a preset value, and the second verification result is verification success, determining that the verification result corresponding to the (i+1) th interval is verification success;
when the value of the circuit check result is a preset value, the circuit check result is used for indicating: the block header hash calculated by the zero knowledge proof circuit is matched with the block header hash of the corresponding block in the full block chain.
In one implementation, one or more instructions in the computer readable storage medium are loaded by the processor 1301 and when executing the block header hash included in the output information of the zero knowledge proof circuit in the proof information of the i+1th interval according to the block header of the target block in the i th interval, to obtain the second verification result, specifically execute the following steps:
acquiring a block header hash of a first reference block in an ith interval from the proof information of the ith interval; the first reference block is a block having a block height 1 smaller than a block height of the target block in the i-th section;
calculating the block head hash of the target block in the ith interval according to the block head hash of the first reference block;
Comparing the calculated block header hash of the target block in the ith interval with the output information of the zero knowledge proof circuit in the proof information of the ith interval, and obtaining a first comparison result;
obtaining the block header hash of the second reference block in the (i+1) th interval from the proof information of the (i+1) th interval; the second reference block is a block having a block height in the i+1th section that is 1 smaller than the block height of the target block in the i+1th section;
calculating the block head hash of the target block in the (i+1) th interval according to the block head hash of the second reference block;
comparing the calculated block head hash of the target block in the (i+1) th interval with the output information of the zero knowledge proof circuit in the proof information of the (i+1) th interval, and comparing the block head hash of the target block in the (i) th interval with the output information of the zero knowledge proof circuit to obtain a second comparison result;
if the first comparison result is successful and the second comparison result is successful, determining that the second verification result is successful.
In one implementation, one or more instructions in a computer-readable storage medium are loaded by processor 1301 and further perform the steps of:
Responding to a transaction inquiry event aiming at the target transaction, and sending a transaction inquiry request to the full-quantity node, wherein the transaction inquiry request comprises the block height corresponding to the target transaction, so that the full-quantity node determines the block to which the target transaction belongs based on the block height corresponding to the target transaction;
receiving the block head 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, wherein the block head of the block to which the target transaction belongs is returned by the full node in response to the transaction inquiry request;
inquiring whether the target transaction exists in the block to which the target transaction belongs or not based on the block head of the block to which the target transaction belongs and the proof information of the (i+1) th interval, and obtaining an inquiry result;
and outputting the query result.
In one implementation, the transaction inquiry event is an event generated when transaction inquiry information sent by the client is acquired; the transaction inquiry information comprises a transaction hash of the target transaction and a merck path of the target transaction; one or more instructions in the computer-readable storage medium are loaded by the processor 1301 and when executing the proof information based on the block header and the i+1th interval of the block to which the target transaction belongs, query whether the target transaction exists in the block to which the target transaction belongs, and obtain the query result, specifically execute the following steps:
Obtaining the block head hash of the third reference block from the output information of the zero knowledge proof circuit in the proof information of the (i+1) th interval, and calculating the block head hash of the block to which the target transaction belongs according to the block head hash of the third reference block; the third reference block is a block with a block height 1 smaller than the block height of the block to which the target transaction belongs in the (i+1) th interval;
if the calculated block head hash of the block to which the target transaction belongs is the same as the block head 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+1) th interval, generating a merck root based on the transaction hash of the target transaction and the merck path of the target transaction;
if the generated merck root exists in the block header of the block to which the target transaction belongs, a query result is generated, wherein the query result is used for indicating that the target transaction exists in the block to which the target transaction belongs.
In one implementation, the target block refers to a block with the largest block height within the interval.
In another embodiment, the computer-readable storage medium has one or more instructions stored therein; one or more instructions stored in a computer-readable storage medium are loaded and executed by processor 1301 to implement the corresponding steps in the blockchain network-based blocksynchronization method embodiment described above. In a specific implementation, the blockchain network comprises a full-scale node and a lightweight node; the full-quantity node stores a full-quantity blockchain, wherein the full-quantity blockchain comprises N sections, N is an integer larger than 1, each section comprises one or more blocks connected in sequence, each section corresponds to one piece of proving information, and the proving information is used for proving the correctness of the blocks in the corresponding section; the lightweight nodes store block heads of partial blocks in the full-volume block chain; the blockchain node device is a full-scale node, and one or more instructions in a computer-readable storage medium are loaded by the processor 1301 and perform the steps of:
Receiving a block synchronization request sent by a lightweight node;
responding to a block synchronization request, returning the block head of a target block in the (i+1) th interval and the proof information of the (i+1) th interval on the full blockchain to the lightweight node, so that the lightweight node verifies the proof information of the (i+1) th interval based on the block head of the target block in the (i) th interval and the block head of the target block in the (i+1) th interval; after the proof information of the (i+1) th interval is successfully verified, the block head of the target block in the (i+1) th interval is stored into a storage space of the lightweight node by the lightweight node; i=1, 2 … N-1.
In one implementation, one or more instructions in a computer-readable storage medium are loaded by processor 1301 and further perform the steps of:
acquiring a zero knowledge proof circuit generated based on a proposition to be proved, wherein the proposition to be proved is used for indicating to verify the correctness of the block heads of partial blocks in the full block chain;
deploying the block synchronization contract, and dividing a plurality of blocks connected in sequence in the full block chain into N intervals in the process of deploying the block synchronization contract;
invoking a block synchronization contract to set the state of the (i+1) th interval to be an exclusive state, and extracting the block header hash of each block in the (i+1) th interval and the block header hash of a target block in the (i) th interval from the full blockchain; the target block in the ith section is the block with the largest block height in the ith section;
According to the zero knowledge proving circuit, verifying the block head hash of each block in the (i+1) th interval and the block head hash of the target block in the (i) th interval to generate proving information of the (i+1) th interval;
and (5) storing the proof information of the (i+1) th interval into the full blockchain.
In one implementation, the proof information for the (i+1) th interval includes: zero knowledge proof circuit output information; one or more instructions in the computer-readable storage medium are loaded by the processor 1301 and when executed to perform a verification process on the chunk header hash of each chunk in the i+th interval and the chunk header hash of the target chunk in the i+th interval according to the zero knowledge proof circuit, the specific steps are performed as follows:
obtaining the block head hash of a first reference block in the ith interval from the full block chain, and calculating the block head hash of a target block in the ith interval according to the block head hash of the first reference block; the first reference block is a block having a block height 1 smaller than a block height of the target block in the i-th section;
for each block in the (i+1) th interval, calculating the block header hash of each block by adopting the block header hash of the previous block to obtain the block header hash of each block in the (i+1) th interval;
Verifying the calculated block header hash of the target block in the ith interval and the calculated block header hash of each block in the (i+1) th interval to generate a circuit checking result;
wherein the output information of the zero knowledge proof circuit comprises: the block header hash of the target block in the i-th section calculated by the zero knowledge proof circuit is used, the block header hash of each block in the i+1-th section calculated by the zero knowledge proof circuit is used, and the circuit check result is obtained.
In one implementation, one or more instructions in the computer-readable storage medium are loaded by the processor 1301 and when executed to verify the calculated block header hashes of the target blocks within the i-th interval, and the calculated block header hashes of each block in the i+1-th interval, to generate the circuit inspection result, specifically perform the following steps:
comparing the block header hash of the target block in the i-th section calculated by the zero knowledge proof circuit with the block header hash of the target block in the i-th section extracted from the full blockchain;
and comparing 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;
If the comparison results are successful, generating a circuit check result, wherein the value of the circuit check result is a preset value for indicating: the block header hash calculated by the zero knowledge proof circuit is matched with the block header hash of the corresponding block in the full block chain.
In one implementation, the proof information corresponding to the (i+1) th interval further includes: a certification string; one or more instructions in the computer-readable storage medium are loaded by processor 1301 and further perform the steps of:
acquiring 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, which includes a full number of nodes; the verifier-public string is a key used by a verifier, which comprises lightweight nodes;
storing the verifier common string to a full blockchain; the method comprises the steps of,
based on the prover public string, a proving character string generated in the calculation process of the output information is obtained by the calculation of the zero knowledge proving circuit; the generation of the proving string represents: the full-scale nodes prove that the circuit has performed a calculation process based on zero knowledge.
In one implementation, one or more instructions in a computer-readable storage medium are loaded by processor 1301 and further perform the steps of:
If the proof information of the (i+1) th interval is detected to be generated, releasing the exclusive state of the (i+1) th interval; or alternatively, the process may be performed,
and if the time length of the (i+1) th section in the exclusive state is greater than the time length threshold value from the time when the (i+1) th section is set in the exclusive state, releasing the exclusive state of the (i+1) th section.
In the embodiment of the application, the blockchain network comprises a full-quantity node and a lightweight node; the full-volume node stores therein a full-volume blockchain (e.g., a blockchain including block heads of all blocks), and a plurality of blocks sequentially connected in the full-volume blockchain are divided into N sections, where N is an integer greater than 1. The lightweight node can synchronize the block header of the target block and corresponding certification information in the (i+1) th interval on the full block chain from the full node only; then, the lightweight node verifies 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; 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 scheme, the block heads of a small number of blocks can be synchronized from the full-volume block chain of the full-volume node, for example, the block heads of the synchronous generation blocks and the block heads of the target blocks in each interval can be verified according to the small number of block heads, so that the efficiency of block synchronization and verification is improved, the cost required by the block synchronization of the light-weight node is reduced, and the load of the light-weight node is lightened.
Embodiments of the present application also provide a computer program product or computer program comprising 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 cause the blockchain node device to perform the blockchain network-based blocksynchronization method described above.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part 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, the processes or functions described in accordance with embodiments of the present invention are produced in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable devices. The computer instructions may be stored in or transmitted across a computer-readable storage medium. The computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by a wired (e.g., coaxial cable, fiber optic, digital line (DSL)), or wireless (e.g., infrared, wireless, microwave, etc.). Computer readable storage media can be any available media that can be accessed by a computer or data processing device, such as a server, data center, or the like, that contains an integration of one or more of the available media. The usable medium may be a magnetic medium (e.g., a floppy Disk, a hard Disk, a magnetic tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a Solid State Disk (SSD)), or the like.
The foregoing is merely specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art will readily recognize that changes and substitutions are within the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (20)

1. A block synchronization method based on a block chain network, wherein the block chain network comprises a full-quantity node and a lightweight node; the full-quantity node is stored with a full-quantity blockchain, the full-quantity blockchain comprises N sections, N is an integer larger than 1, each section comprises one or more blocks connected in sequence, each section corresponds to one piece of proving information, and the proving information is used for proving the correctness of the blocks in the corresponding section; a block header of a part of blocks in the full block chain is stored in the lightweight node; the method is performed by the lightweight node, the method comprising:
acquiring a block head of a target block in an ith interval on the full blockchain, wherein the proof information of the ith interval is verified successfully; i=1, 2 … N-1;
Synchronizing, from the full-volume node, a block header of a target block in an i+1th interval on the full-volume blockchain, and synchronizing certification information of the i+1th interval;
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;
and if the proof information of the (i+1) th interval is verified successfully, storing the block head of the target block in the (i+1) th interval into a storage space.
2. The method of claim 1, further comprising creating blocks on the full blockchain; the method further comprises the steps of:
synchronizing, from the full-volume node, a block header of an creative block on the full-volume blockchain;
when i=1, verifying the proof information of the ith section according to the block head of the created section and the block head of the target section in the ith section;
and if the verification of the proof information of the ith interval is successful, storing the block head of the target block in the ith interval into a storage space.
3. The method of claim 1, wherein the obtaining the block header of the target block within the ith interval on the full blockchain comprises:
Concurrently acquiring block heads of target blocks in M intervals from the full-quantity nodes, wherein M is an integer, M is E [1, N ], and the ith interval is any one of the M intervals; or alternatively, the process may be performed,
and acquiring a block head of the target block in the ith interval from a storage space in the lightweight node.
4. The method of claim 1, wherein the certification information includes a certification string and output information of a zero knowledge certification circuit; the proving character string is generated by the full-quantity node based on the proving person public string in the calculation process of calculating the output information for the zero knowledge proving circuit; the generation of the proving string represents: the full-scale node having performed 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-scale node;
wherein, the output information of the zero knowledge proof circuit comprises: the zero knowledge proof circuit is adopted to calculate the block header hash of the target block in the ith interval, the zero knowledge proof circuit is adopted to calculate the block header hash of each block in the (i+1) th interval, and the circuit check result is adopted;
The circuit check result is used for indicating: and adopting the zero knowledge proof circuit to calculate whether the obtained block head hash is matched with the block head hash of the corresponding block in the full block chain.
5. The method of claim 4, wherein the full blockchain has stored therein a verifier common string; the verifier-public string is a key used by the verifier; the verifier comprising the lightweight node;
the verifying the proof information of the i+1th section based on the block header of the target block in the i-th section and the block header of the target block in the i+1th section includes:
acquiring the common string of the verifier from the full blockchain, and verifying the proving character string in the proving information of the (i+1) th interval by adopting the common string of the verifier to obtain a first verification result;
reading 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) th interval; the method comprises the steps of,
verifying the hash of the block header contained in the output information of the zero knowledge proof circuit in the proof information of the (i+1) th interval 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 verification success, the value of the circuit checking result is a preset value, and the second verification result is verification success, determining that the verification result corresponding to the (i+1) th interval is verification success;
when the value of the circuit check result is a preset value, the circuit check result is used for indicating: and the block head hash calculated by the zero knowledge proof circuit is matched with the block head hash of the corresponding block in the full block chain.
6. The method of claim 5, wherein verifying the chunk header hash included in the output information of the zero-knowledge proof circuit in the proof information according to the chunk header of the target chunk in the i-th interval, to obtain a second verification result, comprises:
acquiring a block header hash of a first reference block in the ith interval from the proof information of the ith interval; the first reference block is a block of which the block height in the ith section is 1 smaller than the block height of the target block in the ith section;
calculating the block head hash of the target block in the ith interval according to the block head hash of the first reference block;
Comparing the calculated block header hash of the target block in the ith section with the output information of the zero knowledge proof circuit in the proof information of the ith section, and obtaining a first comparison result;
acquiring 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 is a block having a block height in the i+1th section smaller than a block height of a target block in the i+1th section by 1;
calculating the block head hash of the target block in the (i+1) th interval according to the block head hash of the second reference block;
comparing the calculated block header hash of the target block in the (i+1) th interval with the output information of the zero knowledge proof circuit in the proof information of the (i+1) th interval, and obtaining a second comparison result;
and if the first comparison result is successful and the second comparison result is successful, determining that the second verification result is successful.
7. The method of claim 1, wherein the method further comprises:
responding to a transaction inquiry event aiming at a target transaction, and sending a transaction inquiry request to the full-quantity node, wherein the transaction inquiry request comprises a block height corresponding to the target transaction, so that the full-quantity node determines a block to which the target transaction belongs based on the block height corresponding to the target transaction;
receiving the block head 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, wherein the block head of the block to which the target transaction belongs is returned by the full node in response to the transaction inquiry request;
inquiring whether the target transaction exists in the block to which the target transaction belongs or not based on the block head of the block to which the target transaction belongs and the proof information of the (i+1) th interval, and obtaining an inquiry result;
and outputting the query result.
8. The method of claim 7, wherein the transaction inquiry event is an event generated when transaction inquiry information transmitted by a client is acquired; the transaction inquiry information comprises a transaction hash of the target transaction and a merck path of the target transaction;
the querying 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+1) th interval, to obtain a query result, includes:
Obtaining 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+1) th interval, and calculating 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 in the (i+1) th interval being 1 smaller than a block height of a 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+1) th interval, generating a merck root based on the transaction hash of the target transaction and the merck path of the target transaction;
if the generated merck root exists in the block header of the block to which the target transaction belongs, generating a query result, wherein the query result is used for indicating that the target transaction exists in the block to which the target transaction belongs.
9. The method according to any one of claims 1-8, wherein the target block is a block having a maximum block height within a block interval.
10. A block synchronization method based on a block chain network, wherein the block chain network comprises a full-quantity node and a lightweight node; the full-quantity node is stored with a full-quantity blockchain, the full-quantity blockchain comprises N sections, N is an integer larger than 1, each section comprises one or more blocks connected in sequence, each section corresponds to one piece of proving information, and the proving information is used for proving the correctness of the blocks in the corresponding section; a block header of a part of blocks in the full block chain is stored in the lightweight node; the method is performed by the full-scale node, the method comprising:
receiving a block synchronization request sent by the lightweight node;
responding to the block synchronization request, returning the block head of the target block in the (i+1) th interval on the full blockchain and the proof information of the (i+1) th interval to the lightweight node, so that the lightweight node verifies the proof information of the (i+1) th interval based on the block head of the target block in the (i+1) th interval and the block head of the target block in the (i+1) th interval; after the proof information of the (i+1) th interval is successfully verified, the lightweight node stores the block head of the target block in the (i+1) th interval into a storage space of the lightweight node; i=1, 2 … N-1.
11. The method of claim 10, wherein the method further comprises:
acquiring a zero knowledge proof circuit generated based on a proposition to be proved, wherein the proposition to be proved is used for indicating to verify the correctness of the block heads of partial blocks in the full block chain;
deploying a block synchronization contract, and dividing a plurality of blocks connected in sequence in the full block chain into N intervals in the process of deploying the block synchronization contract;
invoking the block synchronization contract to set the state of the (i+1) th interval to be an exclusive state, and extracting the block header hash of each block in the (i+1) th interval and the block header hash of a target block in the (i) th interval from the full blockchain; the target block in the ith interval is the block with the largest block height in the ith interval;
according to the zero knowledge proving circuit, verifying the block header hash of each block in the (i+1) th interval and the block header hash of the target block in the (i) th interval to generate proving information of the (i+1) th interval;
and storing the proof information of the (i+1) th interval to the full blockchain.
12. The method of claim 11, wherein the proof information of the i+1th interval includes: the output information of the zero knowledge proof circuit; the verifying the block header hash of each block in the i+th interval and the block header hash of the target block in the i+th interval according to the zero knowledge proving circuit, to generate proving information of the i+1th interval, including:
acquiring the block head hash of a first reference block in an ith interval from the full blockchain, and calculating the block head hash of a target block in the ith interval according to the block head hash of the first reference block; the first reference block is a block of which the block height in the ith section is 1 smaller than the block height of the target block in the ith section;
for each block in the (i+1) -th interval, calculating the block header hash of each block by adopting the block header hash of the previous block to obtain the block header hash of each block in the (i+1) -th interval;
verifying the calculated block header hash of the target block in the ith interval and the calculated block header hash of each block in the (i+1) th interval to generate a circuit check result;
Wherein, the output information of the zero knowledge proof circuit comprises: and the zero knowledge proof circuit is adopted to calculate the block header hash of the target block in the ith interval, the zero knowledge proof circuit is adopted to calculate the block header hash of each block in the (i+1) th interval, and the circuit check result is adopted.
13. The method of claim 12, wherein the 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+1-th interval, generating the circuit check result, comprises:
comparing the block header hash of the target block in the i-th section calculated by the zero knowledge proof circuit with the block header hash of the target block in the i-th section extracted from the full blockchain;
and comparing the chunk header hash of each chunk in the i+1th interval calculated by the zero knowledge proof circuit with the chunk header hash of the corresponding chunk in the i+1th interval extracted from the full blockchain;
if the comparison results are successful, generating a circuit check result, wherein the value of the circuit check result is a preset value for indicating: and the block head hash calculated by the zero knowledge proof circuit is matched with the block head hash of the corresponding block in the full block chain.
14. The method of claim 12, wherein the proof information corresponding to the i+1th interval further comprises: a certification string; the method further comprises the steps of:
acquiring 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, the prover including the full-quantity node; the verifier public string is a key used by a verifier, the verifier comprising the lightweight node;
storing the verifier common string to the full blockchain; the method comprises the steps of,
based on the prover public string, a proving character string generated in a calculating process for calculating the output information for the zero knowledge proving circuit; the generation of the proving string represents: the full-scale node has performed the calculation process based on the zero knowledge proof circuit.
15. The method of claim 11, wherein the method further comprises:
if the proof information of the (i+1) th interval is detected to be generated, releasing the exclusive state of the (i+1) th interval; or alternatively, the process may be performed,
and if the time counting is started when the i+1th interval is set to be in the exclusive state, and the time length of the i+1th interval in the exclusive state is greater than a time length threshold value, releasing the exclusive state of the i+1th interval.
16. A blockchain network-based blocksynchronization device, wherein the blockchain network comprises a full-scale node and a lightweight node; the full-quantity node is stored with a full-quantity blockchain, the full-quantity blockchain comprises N sections, N is an integer larger than 1, each section comprises one or more blocks connected in sequence, each section corresponds to one piece of proving information, and the proving information is used for proving the correctness of the blocks in the corresponding section; a block header of a part of blocks in the full block chain is stored in the lightweight node; the block synchronization device comprises:
an obtaining unit, configured to obtain a block header of a target block in an ith interval on the full blockchain, where the proof information of the ith interval is verified successfully; i=1, 2 … N-1;
a processing unit, configured to synchronize, from the full-volume node, a block header of a target block in an i+1th interval on the full-volume blockchain, and synchronize certification information of the i+1th interval;
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;
And the processing unit is further configured to store the block header of the target block in the i+1th interval to a storage space if the verification of the proof information of the i+1th interval is successful.
17. A blockchain network-based blocksynchronization device, wherein the blockchain network comprises a full-scale node and a lightweight node; the full-quantity node is stored with a full-quantity blockchain, the full-quantity blockchain comprises N sections, N is an integer larger than 1, each section comprises one or more blocks connected in sequence, each section corresponds to one piece of proving information, and the proving information is used for proving the correctness of the blocks in the corresponding section; a block header of a part of blocks in the full block chain is stored in the lightweight node; the block synchronization device comprises:
the receiving unit is used for receiving the block synchronization request sent by the lightweight node;
the processing unit is used for responding to the block synchronization request, returning the block head of the target block in the (i+1) th interval on the full blockchain and the proof information of the (i+1) th interval to the lightweight node, so that the lightweight node verifies the proof information of the (i+1) th interval based on the block head of the target block in the (i+1) th interval and the block head of the target block in the (i+1) th interval; after the proof information of the (i+1) th interval is successfully verified, the lightweight node stores the block head of the target block in the (i+1) th interval into a storage space of the lightweight node; i=1, 2 … N-1.
18. A block link point apparatus, comprising:
a processor adapted to execute a computer program;
a computer readable storage medium having a computer program stored therein, which when executed by the processor, implements the blockchain network-based blocksynchronization method of any of claims 1-9 or the blockchain network-based blocksynchronization method of any of claims 10-15.
19. A computer readable storage medium, characterized in that the computer readable storage medium stores a computer program adapted to be loaded by a processor and to perform the blockchain network based blocksynchronization method of any of claims 1-9 or to implement the blockchain network based blocksynchronization method of any of claims 10-15.
20. A computer program product comprising computer instructions which, when executed by a processor, implement the blockchain network-based blocksynchronization method of any of claims 1-9 or the blockchain network-based blocksynchronization method of any of claims 10-15.
CN202210039428.1A 2022-01-13 2022-01-13 Block synchronization method, related device, medium and program product Pending CN116483915A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210039428.1A CN116483915A (en) 2022-01-13 2022-01-13 Block synchronization method, related device, medium and program product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210039428.1A CN116483915A (en) 2022-01-13 2022-01-13 Block synchronization method, related device, medium and program product

Publications (1)

Publication Number Publication Date
CN116483915A true CN116483915A (en) 2023-07-25

Family

ID=87216022

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210039428.1A Pending CN116483915A (en) 2022-01-13 2022-01-13 Block synchronization method, related device, medium and program product

Country Status (1)

Country Link
CN (1) CN116483915A (en)

Similar Documents

Publication Publication Date Title
CN107862216B (en) Privacy protection method, device and storage medium for anonymous cross-link transaction
CN107888562B (en) Data verification and transceiving method, node and system for parallel link access to interconnection chain
CN110912707B (en) Block chain-based digital certificate processing method, device, equipment and storage medium
US11190525B2 (en) Blockchain system and permission management method thereof
CN111010376B (en) Master-slave chain-based Internet of things authentication system and method
EP3545665B1 (en) System and method for detecting replay attack
CN111552676A (en) Block chain based evidence storing method, device, equipment and medium
CN112287034B (en) Data synchronization method, equipment and computer readable storage medium
US20230316273A1 (en) Data processing method and apparatus, computer device, and storage medium
CN113055188B (en) Data processing method, device, equipment and storage medium
Wang et al. Capacity of blockchain based Internet-of-Things: Testbed and analysis
US20230037932A1 (en) Data processing method and apparatus based on blockchain network, and computer device
CN110910110B (en) Data processing method and device and computer storage medium
CN113409047B (en) Data processing method, device and equipment based on block chain and readable storage medium
CN116827957B (en) Information processing method, device, equipment and medium based on multi-block chain
Wang et al. Internet of things
US11558179B2 (en) Distributed data storage
CN116483915A (en) Block synchronization method, related device, medium and program product
CN117010889A (en) Data processing method, device, equipment, medium and product
CN116126480A (en) Cross-region block chain processing method and device for transaction, intelligent equipment, medium and product
CN117040929B (en) Access processing method, device, equipment, medium and program product
CN116661674A (en) Data compression method, block synchronization method and related equipment
CN115375304A (en) Data processing method, device, equipment and medium based on block chain
CN116205650A (en) Block chain-based data processing method, equipment and readable storage medium
Ghazi et al. Improved TrustChain for Lightweight Devices

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40088006

Country of ref document: HK