Detailed Description
The invention will be described in detail below with reference to the drawings in connection with embodiments.
DAG (Directed Acyclic Graph) is directed acyclic graph. The block chain based on DAG of the system mainly comprises a consensus node and a witness node.
Each account completes transaction by taking account chains (one account is used as a chain) as a unit, independently accounts, forms a chain structure according to the sequence, and the sending transaction and the receiving transaction of each account are independent and do not interfere with each other. In addition, in one account chain, the transaction block is transmitted, and meanwhile, a DAG structure is formed by supporting a plurality of existing transactions.
The common node is used as a core hub of block circulation and is composed of authoritative trusted nodes to complete the functions of block verification, block witness, block uplink, block broadcasting, block storage and the like. Witness nodes are responsible for supervising and propagating the ledgers. And the data on the chain is pulled to carry out comparison and verification on the data on the chain, and the account book copy is stored, so that the account book is disclosed, transparent, safe and reliable.
Aiming at different pre-consensus of chains, witness nodes can also participate in consensus to carry out block packing operation. In addition, all key data generated during running on the chain can be recorded, the state change process of the chain is completely recorded, and inquiry is provided for the outside, so that the historical running process of the chain can be traced.
The invention provides a new transaction type, namely a certification transaction, which has the characteristics of no need of paying attention to continuity and no attention to specific sequence.
The evidence-based traceable transaction based on the DAG structure allows transactions or data blocks to be processed in parallel, so that different types of data or transactions can be simultaneously uplink without affecting each other, and the transaction throughput is greatly improved. Meanwhile, the DAG structure is connected with a plurality of nodes in the form of a directed acyclic graph, different types of data can be flexibly related through edges of the graph, data redundancy is reduced, and transition expansion of data quantity is avoided.
In order to meet the requirements of higher efficiency and higher efficiency of evidence storage tracing, the invention provides a block chain parallel evidence storage tracing method based on DAG.
The method comprises the steps of firstly, signing data to be authenticated by a user and then sending the data to a network as a transaction, then sequencing the transaction by a system depending on a transaction TimeStamp and a transaction Hash, then checking whether the TimeStamp of the data is within the valid range of the TimeStamp of a current block or not by a node, if the TimeStamp of the transaction is within the valid range, continuing to process and verify the transaction by the node, and after verification, writing the data into a corresponding account chain based on a parallel structure of a DAG. Finally, the network periodically packages the transactions within a period of time into check point blocks, which are used as stable reference points for the synchronization of the whole network, and help the nodes to recover or join quickly.
Specifically, referring to fig. 5 and 6 in combination, the parallel existence check tracing method includes the following steps S1-S4:
s1, transaction transmission, namely submitting the evidence data by a user, generating a unique transaction identifier (namely a transaction Key field) by a system, checking the data integrity and signature validity by a transaction verification node (namely a witness node), broadcasting the transaction to a network after verification, and waiting for sequencing and writing.
S2, sequencing the transactions in the network according to the transaction TimeStamp and the transaction Hash, and if the transaction A references the transaction B, the time sequence of the transaction B must reach consensus of the transaction sequence through asynchronous communication among nodes before the transaction A.
And S3, writing the transaction in parallel, namely verifying the validity and conflict condition of the parent node of the transaction in parallel, and if the transaction passes the verification, writing the transaction in a corresponding position and updating the local account book.
S4, periodically synchronizing, namely after the consensus node triggers a synchronization condition, collecting all evidence and tracing transactions which occur in the current network, generating a merck tree for the collected transactions, calculating merck root hashes, combining the merck root hashes with other key information (time stamps, node signatures and the like) of the current network state, generating block heads, packing the block heads and a transaction list into new blocks, signing the blocks to form new blocks, broadcasting the new blocks to the whole network for other nodes to verify, and when nodes exceeding a certain proportion (such as 2/3) agree on the blocks, confirming the blocks as effective check points, adding the new blocks into a block chain to become stable points of the network state. After the consensus is confirmed, the full network node performs state synchronization based on the new block.
The system sets a time limit (such as half an hour) for each transaction, when the transaction is submitted, the node checks whether the time stamp of the transaction is within the valid range of the current block time stamp, if the time stamp of the transaction is within the valid period, the node continues to process and verify the transaction, and if the time stamp of the transaction exceeds the valid period, the node directly refuses the transaction, so that only the transaction meeting the time limit requirement is ensured to be written into the block chain.
In step S1, a new transaction type-deposit transaction is provided, which does not require attention to continuity nor to a specific order.
Referring to fig. 1, a client sends a forensic transaction to a pool of blockchain nodes. The name of each field in the evidence-based transaction is Hash, timeStamp, key, from, notionAddr, value. The meaning of each field is shown in table one.
Table I, description table of each field of trade
The fields in the block of the DAG-based blockchain are named PARENTHASH, NUMBER, TIMESTAMP, tx list. The meaning of each field is shown in table two.
Table two, block each field description table
The transaction contains a unique Value Key, a TimeStamp TimeStamp, and a Hash Value generated by performing a Hash operation on the Key, value and TimeStamp. During the execution of the transaction, the DAG structure can ensure parallel processing of the transaction, thereby realizing efficient performance.
In step S2, the DAG ensures that each transaction can only be executed after its preceding dependent transaction is completed by maintaining the dependency relationship, timestamp and Hash value between transactions. Therefore, the uplink sequence always accurately reflects the causal relationship and execution logic of the data.
Specifically, the DAG ensures that even if the running order of the transactions is inconsistent, the data of the uplink is still dependent and merged in the correct order by recording the pointing link between each transaction and its dependency relationship, so as to ensure the consistency and the sequency of the data, that is, the earlier the time is, the earlier the order is, and when the time is the same, the smaller the Hash value is, the earlier the order is, and when the time is the same, the order is, according to the Hash value.
Taking fig. 2 as an example, there are four transactions a, B, C, D, where x, y, z and w are Hash values of a, B, C, D, respectively, and x < z, the resulting uplink order is constant regardless of the order in which the transactions are run. Firstly, a=c > D > B is obtained according to the order of the TimeStamp from small to large, and secondly, a > C > D > B is obtained according to the order of the Hash value based thereon. The uplink order of transactions, a- > C- > D- > B, can be taken together as shown in fig. 3.
In step S3, when there are multiple accounts to initiate the deposit transaction at the same time and the same unique value Key is not operated, all the deposit transactions are written in the corresponding account chain in parallel, but when the multiple accounts operate the same unique value Key, the deposit transactions are written in the chain after the transaction sequencing.
The underwriting transaction B is directed to underwriting transaction A in FIG. 4, which illustrates that the writing of transaction B depends on transaction A (transaction A was completed before transaction B), and similarly, the writing of transaction C depends on both transaction D and transaction E (transaction D and transaction E were completed before transaction C), and transaction B and transaction C may be written in parallel.
In step S4, the consensus node generates a new block at predetermined time intervals, and the new block contains all the evidence and trace-to-source transactions already occurring in the current network, and the new block can be regarded as a check point of the blockchain, i.e. a known and commonly confirmed stable point of the current state of the network.
By packing these transactions into blocks, the state synchronization process of the nodes of the whole network can be effectively simplified, the nodes do not need to synchronize all historical transactions every time, and only need to trace back and synchronize the states from the nearest block.
In addition, when a new node is added, the synchronization can be started from the nearest block, thereby avoiding long-time historical transaction verification and improving the node adding and synchronization speed.
Through the process, the integrity and consistency of the data in the system are effectively maintained. Although the provenance tracking transactions are packed into blocks, this process does not involve immediate business logic execution, primarily for data storage and synchronization. Therefore, the processing pressure of each node on the real-time transaction can be reduced, and the evidence-based tracing transaction can be used as a complete reference in the follow-up verification or tracing.
A time limit is set, assuming that the transaction is valid within half an hour, when the time stamp of the transaction exceeds the set valid time limit compared to the time stamp of the current block, the transaction will be considered an invalid transaction and the node will refuse the transaction to be processed.
The invention also provides a block chain parallel storage evidence tracing device based on the DAG, which comprises a transaction sending module, a transaction sequencing module, a transaction parallel writing module, a periodic synchronization module and a transaction timeliness checking module.
The transaction sending module is used for a user to sign data needing to be stored and then send the data serving as a transaction to the system, the system generates a unique transaction identifier, namely a transaction Key field, and the transaction verification node checks the data integrity and the signature validity to obtain the stored transaction.
The transaction sequencing module is used for sequencing the transactions according to the TimeStamp and the transaction Hash of the authenticated transaction, wherein if the transaction A refers to the transaction B, the timing of the transaction B must reach consensus on the transaction sequence through asynchronous communication among nodes before the transaction A.
The transaction parallel writing-in module is used for verifying the validity and conflict condition of the parent node of the transaction in parallel, and if the transaction passes the verification, the transaction is written in the corresponding account chain.
The periodic synchronization module is used for periodically packing transactions within a period of time into new blocks, and uploading the blocks to serve as a stable reference point for full network synchronization so as to help the nodes to recover or join quickly.
The transaction timeliness checking module is used for setting a time limit, and checking whether the transaction within the time limit is valid or not, if yes, the node directly refuses the transaction.
The invention has the following technical characteristics/advantages:
Parallel processing and efficient throughput. The DAG architecture eliminates the bottleneck of sequential execution by processing transactions and data blocks in parallel. Multiple transactions can be simultaneously uplink, so that the transaction processing speed and the throughput of the system are greatly improved, and the higher-frequency data access and traceability requirements can be supported. The parallel processing enables the tracing process to be more efficient, and tracing requests of different businesses or commodities can be responded quickly.
Flexible data association and cross-business tracing. The DAG structure can flexibly connect and associate different types of data by the form of a directed acyclic graph. For example, transactions, certificate information, logistics information and the like in different business fields can be effectively associated in the same graph, so that cross-business tracing and data sharing are realized.
New transaction type-deposit transaction. The transaction type does not need to pay attention to the continuity of the transaction or to the specific sequence, and through the clear dependency relationship and the timestamp record, the real causal relationship of the data can be reflected by the final uplink sequence even if the transaction processing sequence is different, the data inconsistency or the traceability error caused by parallel processing is avoided, the uplink correctness of the transaction is ensured, and the transaction failure probability is effectively reduced.
The above embodiments of the present invention are only examples, and are not intended to limit the present invention, but various modifications and variations can be made to the present invention by those skilled in the art. Any modification, replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.