Disclosure of Invention
Since the block chain based on the DAG in the current market basically adopts a recursive tracing manner to perform tracing acquisition of the preposed transaction, for a brand-new node, the recovery of the book involves a lot of round-trip communication, and a lot of time is consumed.
In view of the above problem, a first aspect of the present disclosure provides a ledger synchronization method based on a DAG blockchain, where the DAG blockchain includes a plurality of transaction blocks and one or more sequence blocks, each transaction block directly refers to another transaction block or sequence block, each sequence block directly refers to a transaction block or another sequence block, each sequence block determines the transaction block directly referred to by the sequence block and a part of the transaction blocks indirectly referred to by the sequence block, the sequence block includes at least a sequence block ID, and the sequence block ID of each sequence block is a sequence number sequentially increasing in a generation time order, and the method includes:
Receiving a sequence block ID of a first sequence block stored by a first blockchain node, wherein the first sequence block is the sequence block with the highest sequence number value of the sequence block IDs stored by the first blockchain node;
determining whether a sequencing block ID of a second locally stored sequencing block is less than a sequencing block ID of the first sequencing block, wherein the second sequencing block is the sequencing block with the highest sequence number value of the locally stored sequencing block IDs;
sending a first synchronization request to the first block chain node in the case that the sequencing block ID of the second sequencing block is determined to be smaller than the sequencing block ID of the first sequencing block, wherein the first synchronization request at least comprises a request for obtaining all sequencing blocks stored in the first block chain node and larger than the sequencing block ID of the second sequencing block and all transaction blocks determined by the sequencing blocks;
an ordering block corresponding to the first synchronization request and a transaction block are received.
According to a first aspect of the disclosure, after receiving the sequencing block and the transaction block corresponding to the first synchronization request, the method further comprises:
determining whether the highest received sequencing block ID is equal to the sequencing block ID of the first sequencing block;
In an instance in which it is determined that the highest received sequenced block ID is less than the first sequenced block ID, sending a second synchronization request to the first blockchain node, wherein the second synchronization request includes at least a request to obtain all sequenced blocks greater than the highest received sequenced block ID and all its identified transaction blocks;
an ordering block corresponding to the second synchronization request and a transaction block are received.
According to the first aspect of the disclosure, in case that the ordered block ID of the first ordered block stored by the first blockchain node is changed, the method further comprises:
after receiving the sequencing block corresponding to the first synchronization request and the transaction block, determining whether the highest sequencing block ID received is equal to the sequencing block ID of the latest first sequencing block;
in an instance in which it is determined that the highest received sequenced block ID is less than the sequenced block ID of the newest first sequenced block, sending a second synchronization request to the first blockchain node, wherein the second synchronization request includes at least a request to obtain all sequenced blocks larger than the highest received sequenced block ID and all transaction blocks determined therefor;
An ordering block corresponding to the second synchronization request and a transaction block are received.
According to the first aspect of the present disclosure, in a case where the sequential block ID of the second sequential block is the same as the sequential block ID of the first sequential block, the method further comprises:
generating a first bit array with the length of m aiming at all first-class transaction blocks stored locally, wherein the first-class transaction blocks are transaction blocks which are not determined by a sequencing block, m is more than or equal to 10000 and less than or equal to 100000, and m is an integer;
receiving a second bit array of length m from the first blockchain node, wherein the second bit array is a bit array generated for all first-class transaction blocks stored in the first blockchain node;
determining whether the first bit array is identical to the second bit array;
in the event that it is determined that the first array of bits is different from the second array of bits, determining one or more first type transaction blocks that are stored by the first block link point but not locally stored;
sending a third synchronization request to the first blockchain node, wherein the third synchronization request at least comprises a request to obtain one or more transaction blocks of a first type stored in the first blockchain node but not locally stored;
Receiving a transaction block corresponding to the third synchronization request.
According to the first aspect of the present disclosure, generating the first bit array or the second bit array of length m for all the first type transaction blocks further comprises:
for each first-class transaction block stored locally or in a chain node of the first block, performing k hash function operations by using the first-class transaction block to obtain k hash values: h1(x)、H2(x),…,Hk(x) Where k is 5 ≦ 10 and k is an integer, x is a block or block hash of the transaction block, and 0 ≦ Hy(x) M (y ═ 1,2, …, k and H ≦ my(x) Is an integer);
generating a source bit array with the length of m, and numbering each bit of the source bit array according to the sequence to form a bit sequence number;
determining the bit sequence number equal to each hash value of each transaction block of the first type;
setting a value of a bit of the source bit array corresponding to the determined bit sequence number to 1 to generate a first bit array or a second bit array of length m.
According to the first aspect of the disclosure, in the event that the first bit array is determined to be different from the second bit array, determining that the first block link point stored but not locally stored transaction block further comprises:
Comparing the value of each bit in the first bit array with the value of the corresponding bit in the second bit array to take the bit sequence number corresponding to the bit with different value existing between the two as the difference bit sequence number;
determining one or more hash values stored in the first blockchain node but not locally stored based on the differential bit sequence number;
determining a first type transaction block stored in the first blockchain node but not stored locally based on the one or more hash values and all hash values of each first type transaction block stored in the first blockchain node.
According to the first aspect of the present disclosure, in a case where any transaction block locally stored does not find a transaction block or a sequence block directly or indirectly referenced thereto, or any sequence block locally stored does not find a transaction block or a sequence block directly or indirectly referenced thereto, the method further includes:
determining the block hash of the transaction block or the sequencing block which is not found and is directly or indirectly referenced based on the head information of the transaction block or the sequencing block which is stored locally;
generating a fourth synchronization request based on the block hash;
Transmitting the fourth synchronization request to the first block link point;
where the first block link point stores a transaction block or sequencing block corresponding to the fourth synchronization request, receiving the respective transaction block or sequencing block from a first block chain node.
In view of the above problem, a first aspect of the present disclosure provides an ledger synchronization apparatus based on a DAG blockchain, where the DAG blockchain includes a plurality of transaction blocks and one or more sequence blocks, each transaction block directly refers to another transaction block or sequence block, each sequence block directly refers to a transaction block or another sequence block, each sequence block determines the transaction block directly referred to by the sequence block and a part of the transaction blocks indirectly referred to by the sequence block, the sequence block includes at least a sequence block ID, and the sequence block ID of each sequence block is a sequence number sequentially increasing in a generation time order, the apparatus including:
a processor; and
a memory for storing instructions that, when executed, cause the processor to:
receiving a sequence block ID of a first sequence block stored by a first blockchain node, wherein the first sequence block is the sequence block with the highest sequence number value of the sequence block IDs stored by the first blockchain node;
Determining whether a sequencing block ID of a second locally stored sequencing block is less than a sequencing block ID of the first sequencing block, wherein the second sequencing block is the sequencing block with the highest sequence number value of the locally stored sequencing block IDs;
sending a first synchronization request to the first block chain node in the case that the sequencing block ID of the second sequencing block is determined to be smaller than the sequencing block ID of the first sequencing block, wherein the first synchronization request at least comprises a request for obtaining all sequencing blocks stored in the first block chain node and larger than the sequencing block ID of the second sequencing block and all transaction blocks determined by the sequencing blocks;
an ordering block corresponding to the first synchronization request and a transaction block are received.
According to a second aspect of the disclosure, after receiving the sequencing block and the transaction block corresponding to the first synchronization request, the instructions when executed cause the processor to further perform the following:
determining whether the highest received sequencing block ID is equal to the sequencing block ID of the first sequencing block;
in an instance in which it is determined that the highest received sequenced block ID is less than the first sequenced block ID, sending a second synchronization request to the first blockchain node, wherein the second synchronization request includes at least a request to obtain all sequenced blocks greater than the highest received sequenced block ID and all its identified transaction blocks; and
An ordering block corresponding to the second synchronization request and a transaction block are received.
According to a second aspect of the disclosure, in the event that a change occurs in an ordered block ID of a first ordered block stored by the first blockchain node, the instructions when executed cause the processor to further perform the following:
after receiving the sequencing block corresponding to the first synchronization request and the transaction block, determining whether the highest sequencing block ID received is equal to the sequencing block ID of the latest first sequencing block;
in an instance in which it is determined that the highest received sequenced block ID is less than the sequenced block ID of the newest first sequenced block, sending a second synchronization request to the first blockchain node, wherein the second synchronization request includes at least a request to obtain all sequenced blocks larger than the highest received sequenced block ID and all transaction blocks determined therefor; and
an ordering block corresponding to the second synchronization request and a transaction block are received.
According to a second aspect of the disclosure, in the case that the sequential block ID of the second sequential block is the same as the sequential block ID of the first sequential block, the instructions when executed cause the processor to further perform the following:
Generating a first bit array with the length of m aiming at all first-class transaction blocks stored locally, wherein the first-class transaction blocks are transaction blocks which are not determined by a sequencing block, m is more than or equal to 10000 and less than or equal to 100000, and m is an integer;
receiving a second bit array of length m from the first blockchain node, wherein the second bit array is a bit array generated for all first-class transaction blocks stored in the first blockchain node;
determining whether the first bit array is identical to the second bit array;
in the event that it is determined that the first array of bits is different from the second array of bits, determining one or more first type transaction blocks that are stored by the first block link point but not locally stored;
sending a third synchronization request to the first blockchain node, wherein the third synchronization request includes at least a request to obtain one or more transaction blocks stored in the first blockchain node but not locally stored;
receiving a transaction block corresponding to the third synchronization request.
According to a second aspect of the present disclosure, generating the first bit array or the second bit array of length m for all the first type transaction blocks further comprises:
For each first-class transaction block stored locally or in a chain of nodes of the first block, performing k hash function operations on the first-class transaction block to obtain k hash values: h1(x)、H2(x),…,Hk(x) Where k is 5 ≦ k ≦ 10 and k is an integer, x is a block or block hash of the transaction block, and 0 ≦ Hy(x) M ≦ m (y ≦ 1,2, …, k and Hy(x) Is an integer);
generating a source bit array with the length of m, and numbering each bit of the source bit array according to the sequence to form a bit sequence number;
determining the bit sequence number equal to each hash value of each transaction block of the first type;
setting a value of a bit of the source bit array corresponding to the determined bit sequence number to 1 to generate a first bit array or a second bit array of length m.
According to a second aspect of the disclosure, in an instance in which it is determined that the first bit array is different from the second bit array, determining that the first block link point stored but not locally stored transaction block further comprises:
comparing the value of each bit in the first bit array with the value of the corresponding bit in the second bit array to take the bit sequence number corresponding to the bit with different value existing between the two as the difference bit sequence number;
Determining one or more hash values stored in the first blockchain node but not locally stored based on the differential bit sequence number;
determining transaction blocks stored in the first blockchain node but not stored locally based on the one or more hash values and all hash values of each transaction block of the first class stored in the first blockchain node.
According to a second aspect of the disclosure, in a case where any transaction block stored locally does not find locally the transaction block or the sequencing block to which it directly or indirectly refers, or any sequencing block stored locally does not find locally the transaction block or the sequencing block to which it directly or indirectly refers, the instructions when executed cause the processor to further perform the following operations:
determining the block hash of the transaction block or the sequencing block which is not found and is directly or indirectly referenced based on the head information of the transaction block or the sequencing block which is stored locally;
generating a fourth synchronization request based on the block hash;
transmitting the fourth synchronization request to the first block link point; and
where the first tile link point stores a transaction or sequencing tile corresponding to the fourth synchronization request, receiving the respective transaction or sequencing tile from a first tile chain node.
The account book synchronization method and device based on the DAG block chain can add the sequencing blocks generated periodically into the DAG based block chain, so that the blocks positioned in different sequencing block intervals can be defined in sequence, and the transactions in the same sequence can be synchronized in batch; in addition, for the blocks after the latest sequencing block, the method for account increment synchronization based on the bloom filter is provided by the disclosure, so that the high time and communication cost of recursive acquisition transaction are avoided, and the performance of block synchronization is greatly improved.
Detailed Description
Various exemplary embodiments of the present disclosure are described in detail below with reference to the accompanying drawings. The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of methods and systems according to various embodiments of the present disclosure. It should be noted that each block in the flowchart or block diagrams may represent a module, a segment, or a portion of code, which may comprise one or more executable instructions for implementing the logical function specified in the respective embodiment. It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
As used herein, the terms "include," "include," and similar terms are to be construed as open-ended terms, i.e., "including/including but not limited to," meaning that additional content can be included as well. The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment," and so on.
Techniques, methods, and apparatus known to one of ordinary skill in the relevant art may not be discussed in detail but are intended to be part of the specification where appropriate. For the connection between the units in the drawings, it is only for convenience of description that at least the units at two ends of the connection are in communication with each other, and is not intended to limit the inability of communication between the units that are not connected.
Embodiments of the present disclosure focus primarily on the following technical issues: all running nodes in the DAG-based blockchain network have a complete copy of the DAG ledger, so that structural consensus of the ledger can be achieved. When a node does not have a full copy, restoration and synchronization from neighboring nodes is required. Since DAG is a one-way graph structure, according to the way it is generated, the next block (e.g., transaction block or sequencing block) records the hash value of the previous block (e.g., transaction block or sequencing block), but the previous block does not record the hash value of the next block, and the whole network is not strictly ordered, making the restoration work for the DAG ledger difficult.
To address the above issues, the present disclosure enables transaction blocks located within different sequencing block regions to be determined (i.e., have the same transaction height) and enables transaction blocks having the same transaction height to be batch synchronized by adding regularly generated sequencing blocks to a DAG-based blockchain. For blocks (e.g., transaction blocks) after the latest sequencing block, the present disclosure also proposes a bloom filter-based ledger increment synchronization method, which avoids the high time and communication cost of recursively acquiring transactions, and greatly improves the performance of block (or ledger) synchronization.
Fig. 1 illustrates an exemplary flow diagram of a ledger synchronization method based on a DAG blockchain.
In the disclosure, the DAG-based blockchain includes a plurality of transaction blocks and one or more sequence blocks, and each transaction block directly refers to other transaction blocks or sequence blocks, each sequence block directly refers to a transaction block or other sequence blocks, each sequence block determines the transaction block directly referred to by the sequence block and a part of the transaction blocks indirectly referred to by the sequence block, the sequence block includes at least a sequence block ID, and the sequence block ID of each sequence block is a sequence number sequentially increasing according to a generation time sequence.
As shown in fig. 3, in the structure of the DAG-based blockchain, the following block (e.g., transaction block or sequence block) needs to link one or more known previous blocks (e.g., transaction block, sequence block and/or creation block) in the generation process, and the header information of the general block includes the hash value of the two previous blocks, so that the whole ledger exhibits a mesh structure. In the present disclosure, the header information of the transaction block includes at least transaction height, transaction type, source account information, destination account information, and the like, in addition to the hash value of its two preceding blocks.
In the present disclosure, the network periodically generates and broadcasts a sequence block by common consensus (for example, Power of Working (PoW), rights of interest (Power of stamp, PoS), Delegated rights of interest (DPoS), Practical Byzantine Fault Tolerance (PBFT), etc.); the head information of the sequence block at least comprises transaction height, sequence block ID which is strictly and orderly increased, transaction sequence and other information besides the hash value of two front blocks. In this disclosure, the first block in the DAG-based chain of blocks is referred to as a genesis-block, which is a sequenced block with sequence number 0 of the sequenced block ID.
In fig. 3, a sequence block with a sequence number of 0 (i.e., a creation block) and sequence blocks Seq1, Seq2, Seq3 (the sequence block IDs of which are 1, 2, 3, respectively) can be seen, and each sequence block can perform a deterministic operation on a part of transaction blocks, for example, as shown in fig. 3, the sequence block Seq1 determines a plurality of transaction blocks in the area (1) so that the transaction height (i.e., the sequence block ID) of the sequence block Seq1 is the same as the transaction height of each transaction block determined by the sequence block Seq 1; the sequence block Seq2 identifies a plurality of transaction blocks in the region (2) such that the transaction height (i.e. the sequence block ID) of the sequence block Seq2 is the same as the transaction height of each transaction block identified by it; the sequence block Seq3 identifies a plurality of transaction blocks in region (3) such that the transaction height (i.e., the sequence block ID) of sequence block Seq3 is the same as the transaction height of each transaction block identified by it.
In this embodiment, any blockchain node (which may be referred to as a "local blockchain node" in this disclosure) may implement the method shown in fig. 1, specifically as follows:
step 110: an ordering block ID of a first ordering block stored by a first blockchain node is received. Wherein the first sequence block is a sequence block with a highest sequence number value of sequence block IDs stored by the first blockchain node.
For example, when a first block chain node stores therein a sequence block whose sequence block ID is equal to 0,1,2,3,4,5, respectively, the first sequence block is a sequence block whose sequence block ID is 5.
Step 120: it is determined whether the sequencing block ID of the second sequencing block stored locally is less than the sequencing block ID of the first sequencing block. Wherein the second sequence block is a sequence block with a highest sequence number value of a locally stored sequence block ID.
For example, when a sequence block whose sequence block ID is equal to 0,1,2, or 3 is stored in the local block chain node, the second sequence block is a sequence block whose sequence block ID is 3.
Step 130: in the event that it is determined that the sequencing block ID of the second sequencing block is less than the sequencing block ID of the first sequencing block, a first synchronization request is sent to the first blockchain node. Wherein the first synchronization request includes at least a request to obtain all sequenced blocks stored in the first blockchain node that are larger than the sequenced block ID of the second sequenced block and all transaction blocks for which it has been determined.
For example, in the above embodiment, the first synchronization request sent by the local blockchain node to the first blockchain node includes the sequence blocks whose sequence block IDs 4 and 5 are requested to be obtained and all transaction blocks determined by the sequence blocks.
Step 140: an ordering block corresponding to the first synchronization request and a transaction block are received.
In the present disclosure, a local blockchain node may issue a plurality of first synchronization requests in sequence in order of the sequenced block IDs. For example, in the above embodiment, the first synchronization request first issued by the local blockchain node includes only the sequence block whose sequence block ID is 4 and its identified transaction block; in the case of receiving the corresponding sequence block and its identified transaction block, the first synchronization request reissued by the local blockchain node includes only the sequence block and its identified transaction block requesting to obtain a sequence block ID of 5, and then the corresponding sequence block and its identified transaction block are received from the first blockchain node.
After step 140, the blockchain node also performs the following operations:
first, it is determined whether the highest received sequencing block ID is equal to the sequencing block ID of the first sequencing block.
Second, in the event that it is determined that the highest received sequenced block ID is less than the sequenced block ID of the first sequenced block, a second synchronization request is sent to the first blockchain node, wherein the second synchronization request includes at least a request to obtain all sequenced blocks larger than the highest received sequenced block ID and all transaction blocks it determines.
Third, an ordering block and a transaction block corresponding to the second synchronization request are received.
The above steps are used in this disclosure to ensure that the local blockchain node can synchronously obtain all sequenced blocks and corresponding transaction blocks stored in the first blockchain but not stored in the local blockchain node.
In addition, in the case where the sequence block ID of the first sequence block stored in the first block chain node is changed, the block link point may further perform the following steps:
first, after receiving the sequencing block corresponding to the first synchronization request and the transaction block, it is determined whether the highest sequencing block ID received is equal to the sequencing block ID of the latest first sequencing block.
Second, in the event that it is determined that the highest received sequenced block ID is less than the sequenced block ID of the newest first sequenced block, a second synchronization request is sent to the first blockchain node, wherein the second synchronization request includes at least all sequenced blocks that are requested to obtain greater than the highest received sequenced block ID and all transaction blocks that it determines.
For example, when the sequence block ID of the first sequence block stored by the first blockchain node is 7, and the highest sequence block ID received by the local blockchain node is 5 after step 140, the local blockchain node needs to send a second synchronization request to the first blockchain node to request the sequence block with sequence block ID of 6,7 and the determined transaction block.
Finally, an ordering block and a transaction block corresponding to the second synchronization request are received.
The embodiment disclosed in fig. 1 is a process where there is a difference in sequencing block ID sequence numbers between a local block link point and a first block link point, such that the local block chain nodes are all synchronized to obtain the corresponding blocks of the first block chain node. The disclosed embodiments can avoid the high time and communication costs of acquiring blocks in a recursive manner.
As shown in fig. 2, when the sequence block ID of the second sequence block is the same as the sequence block ID of the first sequence block, the incremental synchronization block needs to be implemented by using a bloom filter technique, and the local blockchain node specifically performs the following steps:
step 210: a first bit array of length m is generated for all transaction blocks of a first type stored locally. Wherein the first type transaction block is a transaction block that has not been committed by the sequencing block, 10000 ≦ m ≦ 100000 and m is an integer.
In this disclosure, generating the first bit array or the second bit array of length m for all of the first type transaction blocks further comprises:
firstly, for each transaction block of a first type stored locally or in a chain node of the first block, performing k hash function operations agreed in advance by using the transaction block of the first type to obtain k hash values: h 1(x)、H2(x),…,Hk(x) Where k is 5 ≦ 10 and k is an integer, x is a block or block hash of the transaction block, and 0 ≦ Hy(x) M (y ═ 1,2, … k and H ≦ my(x) Is an integer).
Second, a source bit array of length m is generated and each bit of the source bit array is numbered in order to form a bit sequence number.
In the present embodiment, each bit initial setting value in the generated source bit array is set to 0.
Third, the bit sequence number equal to each hash value of each transaction block of the first type is determined.
Fourth, a value of a bit corresponding to the determined bit sequence number in the source bit array is set to 1 to generate a first bit array or a second bit array of length m.
For example, the hash values of a certain first type transaction block in a certain blockchain node are respectively 0,3,5,7,300, and the hash values of another first type transaction block are respectively 1,25,100,107,300, so that the 0 th bit, 3 rd bit, 5 th bit, 7 th bit, 300 th bit, 1 st bit, 25 th bit, 100 th bit, 107 th bit of the generated bit array are all 1.
The present disclosure employs a combination of hash functions and bloom filter techniques to enable determination of each particular first-type transaction block stored by any blockchain node (e.g., first blockchain node or local blockchain node).
Step 220: receiving a second array of bits of length m from the first blockchain node. Wherein the second bit array is a bit array generated for all first type transaction blocks stored in the first blockchain node.
Step 230: determining whether the first array of bits is the same as the second array of bits.
Step 240: determining one or more first type transaction blocks that are stored by the first block link point but not locally stored, if it is determined that the first bit array is different from the second bit array.
The method specifically comprises the following steps:
first, the value of each bit in the first bit array is compared with the value of the corresponding bit in the second bit array, so that the bit sequence number corresponding to the bit having a different value existing between the two is used as the differential bit sequence number.
Secondly, one or more hash values stored in the first blockchain node but not locally stored are determined based on the differential bit sequence number and all hash values of each transaction block of the first type stored in the first blockchain node.
Finally, a first type transaction block stored in the first blockchain node but not stored locally is determined based on the one or more hash values and all hash values of each first type transaction block stored in the first blockchain node.
For example, bits 0, 1, 3, 5, 7, 25, 100, 107, and 300 in the first bit array are respectively equal to 1, and bits 0, 1, 3, 5, 7, 25, 100, 107, 251, 295, and 300 in the second bit array are respectively equal to 1; it can be determined that the difference bit sequence numbers of the first bit array and the second bit array are bits 251 and 295. Then checking which one or more first type transaction blocks stored in the first blockchain node have a hash value equal to 251 or 295; in the event that one or more corresponding first type transaction blocks are found, it is determined that these first type transaction blocks are first type transaction blocks that are not stored by the local blockchain node.
Step 250: sending a third synchronization request to the first blockchain node. Wherein the third synchronization request comprises at least a request to obtain one or more transaction blocks of the first type stored in the first blockchain node but not stored locally.
Step 260: receiving a transaction block corresponding to the third synchronization request.
The first blockchain node obtains its transaction blocks that are not stored but are stored in the local blockchain node from the local blockchain node in a manner similar to steps 220-260.
The bloom filter based delta synchronization DAG-based block chain block technology disclosed by the present disclosure can significantly reduce the number of times and size of message traffic in the delta synchronization process. For example, when 10000 blocks not stored by the local blockchain node (n is 10000) need to be synchronized, if k is 8 hash functions, only 558,962 bits (68KB) need to be transmitted, that is, information on whether the first block link point owns each block can be transmitted to the local blockchain node, and the false positive rate (i.e., the probability of a block which is not stored but is considered to be stored) is less than 0.00001%, and the specific algorithm is as follows:
p=pow(1-exp(-k/(m/n)),k);
Wherein, p is false positive rate; n-the number of blocks that need to be synchronized; m-the length of the bit array.
And, the false negative rate (i.e., the probability of a block that is itself stored but is considered to be not stored) is 0. Compared to the existing common synchronization strategy, according to the case of a network structure (e.g., block chain based on DAG), at least log2(10000) -1-12 times, and at most 9999 times are required to be communicated back and forth; the missing transaction of 99.99999% can be obtained by only carrying out 1 round trip communication in the method.
In addition, in the present disclosure, when any transaction block locally stored does not find a transaction block or a sequence block directly or indirectly referenced by it locally, or any sequence block locally stored does not find a transaction block or a sequence block directly or indirectly referenced by it locally, the block link node performs the following steps:
first, based on locally stored header information of transaction blocks or sequenced blocks, a block hash of a transaction block or sequenced block that is not found and to which it refers directly or indirectly is determined.
Second, a fourth synchronization request is generated based on the block hash.
Again, the fourth synchronization request is sent to the first block link point.
Fourth, where the first block link point stores a transaction block or sequencing block corresponding to the fourth synchronization request, the respective transaction block or sequencing block is received from a first block chain node.
In the above embodiment, for the block that the local blockchain node still cannot be synchronized after the full synchronization and the incremental synchronization, the traditional recursive trace-back method is continuously adopted to synchronize the block from the first blockchain node.
Fig. 4 illustrates a schematic block diagram of ledger synchronization device 400 based on a DAG blockchain. The account synchronization device 400 includes at least a processor 410 and a memory 420, wherein the memory 420 has stored therein instructions that, when executed by the processor 410, cause the processor 410 to:
receiving a sequence block ID of a first sequence block stored by a first blockchain node, wherein the first sequence block is the sequence block with the highest sequence number value of the sequence block IDs stored by the first blockchain node;
determining whether a sequencing block ID of a second locally stored sequencing block is less than a sequencing block ID of the first sequencing block, wherein the second sequencing block is the sequencing block with the highest sequence number value of the locally stored sequencing block IDs;
Sending a first synchronization request to the first block chain node in the case that the sequencing block ID of the second sequencing block is determined to be smaller than the sequencing block ID of the first sequencing block, wherein the first synchronization request at least comprises a request for obtaining all sequencing blocks stored in the first block chain node and larger than the sequencing block ID of the second sequencing block and all transaction blocks determined by the sequencing blocks;
an ordering block corresponding to the first synchronization request and a transaction block are received.
In one embodiment consistent with the present disclosure, after receiving the sequencing block and the transaction block corresponding to the first synchronization request, the instructions when executed cause the processor 410 to further perform the following:
determining whether the highest received sequencing block ID is equal to the sequencing block ID of the first sequencing block;
in an instance in which it is determined that the highest received sequenced block ID is less than the first sequenced block ID, sending a second synchronization request to the first blockchain node, wherein the second synchronization request includes at least a request to obtain all sequenced blocks greater than the highest received sequenced block ID and all its identified transaction blocks; and
An ordering block corresponding to the second synchronization request and a transaction block are received.
In one embodiment consistent with the present disclosure, in the event that the ordered block ID of the first ordered block stored by the first blockchain node changes, the instructions when executed cause the processor 410 to further perform the following:
after receiving the sequencing block corresponding to the first synchronization request and the transaction block, determining whether the highest sequencing block ID received is equal to the sequencing block ID of the latest first sequencing block;
in an instance in which it is determined that the highest received sequenced block ID is less than the sequenced block ID of the newest first sequenced block, sending a second synchronization request to the first blockchain node, wherein the second synchronization request includes at least a request to obtain all sequenced blocks larger than the highest received sequenced block ID and all transaction blocks determined therefor; and
an ordering block corresponding to the second synchronization request and a transaction block are received.
In one embodiment consistent with the present disclosure, in the case that the sequential block ID of the second sequential block is the same as the sequential block ID of the first sequential block, the instructions when executed cause the processor to further perform the following:
Generating a first bit array with the length of m aiming at all first-class transaction blocks stored locally, wherein the first-class transaction blocks are transaction blocks which are not determined by a sequencing block, m is more than or equal to 10000 and less than or equal to 100000, and m is an integer;
receiving a second bit array of length m from the first blockchain node, wherein the second bit array is a bit array generated for all first-class transaction blocks stored in the first blockchain node;
determining whether the first array of bits is the same as the second array of bits;
in the event that it is determined that the first array of bits is different from the second array of bits, determining one or more transaction blocks stored by the first block link point but not stored locally;
sending a third synchronization request to the first blockchain node, wherein the third synchronization request at least comprises a request to obtain one or more transaction blocks of a first type stored in the first blockchain node but not locally stored;
receiving a transaction block corresponding to the third synchronization request.
In one embodiment according to the present disclosure, generating the first bit array or the second bit array of length m for all the first type transaction blocks further comprises:
For each first-class transaction block stored locally or in a chain node of the first block, performing k hash function operations by using the first-class transaction block to obtain k hash values: h1(x)、H2(x),…,Hk(x) Where k is 5 ≦ 10 and k is an integer, x is a block or block hash of the transaction block, and 0 ≦ Hy(x) M, y 1,2, … k and Hy(x) Is an integer;
generating a source bit array with the length of m, and numbering each bit of the source bit array according to the sequence to form a bit sequence number;
determining the bit sequence number equal to each hash value of each transaction block of the first type;
setting a value of a bit of the source bit array corresponding to the determined bit sequence number to 1 to generate a first bit array or a second bit array of length m.
In one embodiment consistent with the present disclosure, in an instance in which the first bit array is determined to be different from the second bit array, determining that the first block link point stored but not locally stored transaction block further comprises:
comparing the value of each bit in the first bit array with the value of the corresponding bit in the second bit array to take the bit sequence number corresponding to the bit with different value existing between the two as the difference bit sequence number;
Determining one or more hash values stored in the first blockchain node but not locally stored based on the differential bit sequence number;
determining transaction blocks stored in the first blockchain node but not stored locally based on the one or more hash values and all hash values of each transaction block of the first class stored in the first blockchain node.
In one embodiment consistent with the present disclosure, in the case where any transaction block stored locally does not find its directly or indirectly referenced transaction block or sequencing block locally, or any sequencing block stored locally does not find its directly or indirectly referenced transaction block or sequencing block locally, the instructions when executed cause the processor to further perform the following:
determining the block hash of the transaction block or the sequencing block which is not found and is directly or indirectly referenced based on the head information of the transaction block or the sequencing block which is stored locally;
generating a fourth synchronization request based on the block hash;
transmitting the fourth synchronization request to the first block link point; and
where the first tile link point stores a transaction or sequencing tile corresponding to the fourth synchronization request, receiving the respective transaction or sequencing tile from a first tile chain node.
The ledger synchronization method and apparatus based on DAG blockchain disclosed herein add a plurality of sequencing blocks in the DAG blockchain to facilitate topologically ordered splitting of the blockchain (i.e., defining transaction blocks directly referenced by a certain sequencing block and partial transaction blocks indirectly referenced). The method aims at different transaction blocks and sequencing blocks stored in different blockchain nodes to carry out full-quantity synchronization or adopt a bloom filter technology to carry out mutual increment synchronization, thereby greatly improving the performance of block synchronization.
Alternatively, the above-described ledger synchronization method can be implemented by a computer program product. The computer program product may include a computer-readable storage medium having computer-readable program instructions embodied thereon for carrying out various aspects of the present disclosure. The computer-readable storage medium may be a tangible device that can hold and store the instructions for use by the instruction execution device. The computer readable storage medium may be, for example, but not limited to, an electronic memory device, a magnetic memory device, an optical memory device, an electromagnetic memory device, a semiconductor memory device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium include a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a Static Random Access Memory (SRAM), a portable compact disc read-only memory (CD-ROM), a Digital Versatile Disc (DVD), a memory stick, a floppy disk, a mechanical coding device, a punch card or an in-groove raised structure such as with instructions stored thereon, and any suitable combination of the foregoing. Computer-readable storage media as used herein is not to be interpreted as a transitory signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., optical pulses through a fiber optic cable), or an electrical signal transmitted through an electrical wire.
The above description is only an alternative embodiment of the present disclosure and is not intended to limit the embodiment of the present disclosure, and various modifications and changes may be made to the embodiment of the present disclosure by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the embodiments of the present disclosure should be included in the scope of protection of the embodiments of the present disclosure.
While embodiments of the present disclosure have been described with reference to several particular embodiments, it should be understood that embodiments of the present disclosure are not limited to the particular embodiments disclosed. The embodiments of the disclosure are intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims. The scope of the following claims is to be accorded the broadest interpretation so as to encompass all such modifications and equivalent structures and functions.