WO2021227867A1 - 去中心化分布式数据库的形成方法及系统、电子设备及计算机可读存储介质 - Google Patents

去中心化分布式数据库的形成方法及系统、电子设备及计算机可读存储介质 Download PDF

Info

Publication number
WO2021227867A1
WO2021227867A1 PCT/CN2021/090112 CN2021090112W WO2021227867A1 WO 2021227867 A1 WO2021227867 A1 WO 2021227867A1 CN 2021090112 W CN2021090112 W CN 2021090112W WO 2021227867 A1 WO2021227867 A1 WO 2021227867A1
Authority
WO
WIPO (PCT)
Prior art keywords
block
data
mining
signature
chain
Prior art date
Application number
PCT/CN2021/090112
Other languages
English (en)
French (fr)
Inventor
徐皓
Original Assignee
徐皓
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 徐皓 filed Critical 徐皓
Publication of WO2021227867A1 publication Critical patent/WO2021227867A1/zh

Links

Images

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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • 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

Definitions

  • the invention relates to the technical field of decentralized distributed databases, in particular to a method and system for forming a decentralized distributed database, electronic equipment and computer-readable storage media.
  • Distributed database is a database system maintained by multiple devices (such as computers and servers) connected via a network.
  • Distributed databases can be divided into two types: centralized and decentralized.
  • the centralized distributed database system has a master server and several slave servers, and the database is subject to the records of the master server.
  • the decentralized distributed database system includes multiple nodes, no main server, all nodes have equal status, and rely on consensus algorithms to maintain the consistency of the database.
  • the current decentralized distributed database technology has the problems of slow data processing speed and long delay time.
  • the decentralized distributed database uses a consensus algorithm so that nodes can reach agreement without knowing the data stored in the databases of other accounting nodes, store the same data, and thus maintain the same database.
  • a common consensus algorithm is Proof of Work (POW), that is, all nodes compete to generate new blocks, and the newly generated blocks must provide proof of completion of the workload determined according to the current blockchain state in order to be eligible to be added to the database .
  • POW Proof of Work
  • the difficulty of the proof of work must be large enough and it will take a certain time to complete, in order to distinguish between new blocks and accommodate the delay of block propagation in the network.
  • the workload difficulty is set to make the entire network generate a new block about every 10 minutes, each block is 1MB in size, so the data processing speed is about 7 transactions per second, and the data processing speed is slow.
  • the decentralized distributed database can be used to process transactions, data storage and other scenarios. In these scenarios, after the data is stored in the decentralized distributed database, it will not need to be used immediately, so the delay time of data processing does not affect The efficiency of the system. However, in process-related applications, such as workflow, supply chain management, etc., long data processing delays will lead to a decrease in system efficiency. For example, there are 100 pieces of data to be processed, and the delay time is 5 seconds. If these data are not related and can be processed at the same time, it only takes 5 seconds to process all 100 pieces of data. And if these 100 pieces of data are contextual process data, they can only be processed sequentially, and it takes 500 seconds to process all 100 pieces of data. Therefore, the delay time is the key to determining the efficiency of the system. However, the existing decentralized distributed databases using the POW algorithm have the problem of high latency.
  • the present invention provides a decentralized distributed database method, which aims to solve the above technical problems.
  • the present invention also provides a method for forming a decentralized distributed database.
  • the method specifically includes the following steps:
  • a data block contains a reference to another data block.
  • the data block forms a chained data structure through the reference relationship, which is called a data chain.
  • the mining right block contains a reference to another mining right block, and the mining right block passes The reference relationship forms a chained data structure, which is called the mining rights chain;
  • the mining rights block contains the miner's address
  • the data block includes the signature block
  • the signature block contains the application data and the digital signature of the miner's address in the mining rights block on the main chain of the mining rights chain to the packaged application data.
  • the digital signature is called block signature.
  • block signatures are made with the miner addresses in the mining rights blocks, and each miner address generates a predetermined number of signature blocks, and the generated signature blocks Join the database in turn and broadcast to other computing devices.
  • the signature block refers to the data block containing the digital signature.
  • the data block also includes the POW block
  • the received application data is packaged to generate a POW block, the newly generated POW block is added to the database, and the calculation is performed Device broadcast.
  • the mining right block contains a reference to a data block, and the data block referenced by the mining right block is called the optimal data block.
  • the legal mining right block must meet the following conditions:
  • the optimal data block height h of the mining right block is not less than the optimal data block height H of its parent mining right block, that is, h ⁇ H;
  • the parent mining right block is the last mining right block on the main chain of the current mining right chain
  • the miner address of the mining right block is not in the last N-1 mining right blocks of the main chain of the mining right chain, where N is the size of the mining right chain window.
  • the parent data block of the signature block is the last data block of the main chain of the current data chain
  • the signature block has a legal block signature made by the address of more than half of the active miners.
  • the miner address is the address of the miner in the mining right block of the mining right chain window of the parent block of the signature block.
  • the mining rights chain window of the signature block is the mining rights chain window of the parent block of the signature block sliding backward n mining rights areas
  • the mining right chain window formed by the block; otherwise, the mining right chain window of the signed block is the same as the mining right chain window of the parent block of the signature block, where n is the sliding step of the mining right chain window of the signed block, M is the maximum number of signature blocks corresponding to each mining rights chain window.
  • the method for determining the mining rights chain window of the POW block is as follows:
  • the mining right chain window of the POW block is the mining right chain window composed of m mining right blocks sliding backward from the mining right chain window of the parent block of the POW block, where m is the sliding mining right chain window of the POW block Stride.
  • the workload proof of the mining right block satisfies the difficulty value determined according to the function of the waiting length, which is the difference between the height of the mining right block and the height of the mining right chain window of the optimal data block of the mining right block.
  • the application data includes transaction data.
  • the mining right block includes a set of output points, and the output point is a reference to the transaction output. Verifying the legality of the mining right block also includes:
  • the size of the signature block does not exceed the periodically adjusted maximum signature block capacity.
  • the periodical adjustment method is to determine the maximum signature block capacity of the next cycle according to the average block production time of the signature blocks in the cycle.
  • the application data includes database transaction data
  • the application data includes database transaction data
  • the corresponding database transaction is executed according to the database transaction data in the data block of the main chain of the data chain, or the corresponding database transaction is executed according to the database transaction data in the legal data block. Database transaction.
  • the present invention also provides a decentralized distributed database system, which is composed of computing devices communicating with each other through a network, and the computer device is configured with a database formed based on the above-mentioned decentralized distributed database forming method.
  • the signature block is jointly generated by N computing devices, and the generated signature block includes block signatures made by more than N/2 miner addresses; the miner address is in the mining rights chain window of the parent block of the signature block Miner address.
  • the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor.
  • the processor implements the decentralized distributed database as described above when the program is executed. Formation method.
  • the present invention also provides a computer-readable storage medium that stores a program for realizing the method for forming a decentralized distributed database as described above.
  • the decentralized distributed database is to maintain the consistency of the database between nodes, and each node needs to execute the same consensus algorithm.
  • the most common consensus algorithm in the blockchain is proof of work, that is, the new block needs to provide proof of work that has completed the difficulty determined according to the state of the blockchain, and only those that provide proof of work Blocks are legal blocks.
  • the node selects the chain with the longest or the most accumulated workload among the candidate chains as the effective chain.
  • blockchain technology can also be used to store other types of data. For example, using the characteristics of blockchain data that cannot be tampered with, blockchain technology is also used for evidence storage.
  • the current blockchain technology is not suitable for processing process data, because there is a dependency between the front and back links of the process, and the high latency of the blockchain technology will lead to a decrease in system efficiency.
  • the present invention proposes to separate the acquisition of the right to the output block from the behavior of the actual output block.
  • the node obtains the right to the output block in the future in a competitive manner.
  • the node can produce Multiple blocks, not just one block. Therefore, the number of data blocks corresponding to each proof of work can be arbitrarily set by the system.
  • the time interval and delay time of block output can be arbitrarily short, and the data processing can be high enough. It can meet the needs of real-time applications and process processing.
  • the database includes two chain data structures. One of them is called the mining rights chain, and the other is called the data chain.
  • the block in the mining rights chain records the address of the miner who obtained the accounting rights, and does not contain application data.
  • the blocks in the mining right chain are generated in a competitive manner, and it takes a relatively long time to generate a mining right chain block. For example, hash collisions are used to generate mining rights chain blocks that meet a certain difficulty value.
  • the data blocks are generated by the corresponding miners in turn according to the order of the blocks in the mining rights chain, and each miner can generate a batch of predetermined number of data blocks. In this way, the demand for any block rate can be met without sacrificing safety.
  • the present invention proposes two methods.
  • One method is to allow two types of data blocks, called signature blocks and POW blocks, respectively.
  • the signature blocks are generated by the miners who obtain the block rights according to the order of the miners in the mining rights chain in the above manner.
  • a POW block is a data block generated by a traditional proof-of-work method. Any node can generate a POW block. It is not restricted by the order of miners in the mining rights chain, but it takes a relatively long time to generate a block.
  • Another method is to make the signature block generated by a predetermined number of miners instead of one miner, and the signatures of more than half of the miners are valid.
  • the present invention uses a method of sliding the mining rights chain window to determine which group of miners can participate in generating the signature block. As long as the number of failed nodes is less than half of the predetermined number, the system can stably generate new signature blocks without affecting performance. When the number of failed nodes exceeds half of the predetermined number, the nodes in the system generate POW blocks, and the system performance is affected, but it will not freeze. However, this impact is short-lived, because the POW block mode will drive the window of the mining rights chain to slide, causing the faulty node to lose the right to produce blocks, and other nodes to obtain the right to produce blocks.
  • the data that can be stored in the data block is not limited to transaction data, and can be any type of data.
  • the data in the data block may be database transaction data.
  • the node executes the database transaction corresponding to the database transaction data in the data block. Therefore, a universal decentralized distributed database is formed. Due to the low-latency characteristics of the present invention, this universal decentralized distributed database can be used in applications such as workflow and supply chain management.
  • the method proposed by the present invention is a decentralized method, because any node can finally obtain the right to generate data blocks through competition to generate mineral rights blocks.
  • the security of the database is decoupled from the processing speed.
  • the invention can achieve high processing speed without sacrificing safety, or improve safety without reducing processing speed, and even achieve high safety and high processing speed at the same time.
  • Figure 1 is a global schematic diagram of an embodiment of a distributed database of the present invention
  • Figure 2 is a schematic diagram of a computing device according to an embodiment of the present invention.
  • Figure 3 is a schematic diagram of a mining right chain according to an embodiment of the present invention, where (a) is the chain data structure of the mining right chain, and (b) is the branched data structure of the mining right chain;
  • FIG. 4 is a schematic diagram of a data link according to an embodiment of the present invention, in which (a) is a chain data structure of the data link, and (b) is a branched data structure of the data link;
  • FIG. 5 is a schematic diagram of the relationship between the mining rights chain reference data chain according to the embodiment of the present invention.
  • Fig. 6 is a schematic diagram of a mining right chain window according to an embodiment of the present invention.
  • FIG. 7 is a schematic diagram of the difficulty value of an embodiment of the present invention.
  • Some embodiments of the present invention are methods of forming a distributed database on a group of computing devices that communicate with each other through a network. As shown in Figure 1, multiple computing devices communicate with each other through a network, and each computing device includes a processor and a memory, and a database is stored in the memory. For any item of valid data in the distributed database, the computing device executes the method described in the present invention, and all computing devices will eventually store the same valid information.
  • the computing device includes a database, a storage unit storing the database, and a processing unit, and is equipped with a communication module, which can receive mining rights blocks, data blocks, and application data from other computing devices.
  • Application data is data related to application scenarios, such as blockchain transaction data, database transaction data, deposit certificate data, company business data, personnel file data, and any data stored and processed in traditional databases are all referred to in the present invention.
  • Application data is data related to application scenarios, such as blockchain transaction data, database transaction data, deposit certificate data, company business data, personnel file data, and any data stored and processed in traditional databases are all referred to in the present invention.
  • Application data is data related to application scenarios, such as blockchain transaction data, database transaction data, deposit certificate data, company business data, personnel file data, and any data stored and processed in traditional databases are all referred to in the present invention.
  • Application data is data related to application scenarios, such as blockchain transaction data, database transaction data, deposit certificate data, company business data, personnel file data, and any data stored and processed in traditional databases are all referred to in
  • the computing device can be a single computer or server; it can also be a group of computers or servers, where each computer or server only executes part of the methods in the present invention, undertakes part of the functions, and collectively executes the completeness of the present invention. The method assumes the complete function.
  • a physical computer or server can appear as multiple computers or servers in the network. In this case, a physical computer or server should be regarded as multiple computers or servers in the present invention.
  • a computing device not just a computing device.
  • Each computing device is configured with a pair of public key and private key.
  • an address can be generated.
  • the generated address is called the miner address.
  • the miner address is the public key itself, or the hash value of the public key.
  • the public key and the private key are a pair of mathematically related numbers, but the private key cannot be calculated based on the public key.
  • the private key is not open to the public, and is only kept by the owner of the private key, and is used to sign data.
  • a digest is generated for the data that needs to be signed, and then the digest is encrypted with a private key.
  • the decryption If the decryption is successful, it means that the private key associated with the public key is used for encryption. Then the address is generated according to the public key. If the address is the same as the address of the digital signature provider, the digital signature is considered to be authentic. In the present invention, the aforementioned address is called the address of the miner, and the digital signature made in this way is called the digital signature made by the address of the miner.
  • the data in the database includes two chained data structures composed of two types of blocks. These two types of blocks are mineral rights blocks and data blocks.
  • Each mining right block contains a reference to another mining right block.
  • the cited mining right block is called the parent block or parent mining right block of the mining right block; the mining right block is called the The child block of the parent block.
  • the mining right block references the parent block by including the hash value of the previous mining right block in the block data.
  • All mining rights blocks in the database form a chain data structure as shown in Figure 3(a) through their parent block hash value, which is called a mining rights chain.
  • Each data block contains a reference to another data block, the referenced data block is called the parent block or parent data block of the data block; the data block is called the child area of the parent block Piece.
  • the data block refers to the parent block by including the hash value of the previous data block in the block data. All data blocks in the database form a chained data structure as shown in Figure 4(a) through their parent block hash value, which is called a data chain.
  • Each mining right block includes the following data, see Table 1:
  • the hash value of the parent mining right block The hash value of the previous mining right block Miner address An address generated from the public key Optimal data block hash value
  • Miners are a concept derived from blockchain technology.
  • miners refer to computing devices that participate in competition to generate blocks.
  • computing devices are also called miners or nodes.
  • the miner is configured with a pair of public key and private key.
  • Miners are identified by a miner's address, and other miners verify their qualifications, identities, or rights by verifying the digital signature corresponding to the miner's address.
  • Miners and physical equipment do not necessarily have a one-to-one correspondence.
  • a group of physical devices can be organized to form a mining pool, and jointly generate blocks.
  • the mining revenue belongs to a miner's address, and the revenue is further distributed within the mining pool.
  • the mining pool can be regarded as a miner.
  • two computers or servers are configured, one of which specifically generates a mining right block, and the miner address in the generated mining right block is a certain one. Address; and the second one specifically generates data blocks, and the generated signature blocks are all signed with the miner's address.
  • These two computers or servers form a miner.
  • Computing equipment, miners, or nodes are synonymous, and can be defined as a device configured with a pair of public and private keys, identified by a miner’s address, and capable of data storage, processing, and network communication.
  • the optimal data block is a data block in the data chain.
  • Miners can choose arbitrarily within a certain range. Miners generally choose the last data block in the main chain of the data chain as the optimal data block. Miners can also choose the optimal data block of the parent mining right block or any data block after it as the optimal data block of the child mining right block.
  • multiple mining right blocks with the same parent mining right block hash value are allowed to exist in the database, thus forming a data structure with branches as shown in Figure 3(b).
  • the longest Or the branch with the most accumulated workload is the effective chain, called the main mining right chain or the main chain of the mining right chain, and the other branches are invalid data, called the side mining right chain or the mining right chain side chain;
  • the mining rights block becomes the branch with the longest or the most accumulated workload
  • the miners reorganize the data in the database to make the side mining right chain become the new main mining right chain, and the original main mining right chain becomes Side mining rights chain.
  • this mining right chain the main mining right chain or the main mining right chain.
  • multiple data blocks with the same parent data block hash value are allowed to exist in the database, thus forming a data structure with branches as shown in Figure 4(b).
  • the longest branch The valid chain is called the main data chain or the main data chain
  • the other branches are invalid data, which is called the side data chain or the data chain side chain.
  • POW block There are two types of data blocks: POW block and signature block. All data blocks contain the packaged application data and the block hash value of the parent data block. In addition, the POW block also contains proof of work, and the signature block also contains the block signature.
  • the block hash value is a value obtained by performing a hash operation on the data in the block including the block signature. Therefore, the signature blocks in the database of all miners not only have the same application data, but also have the same block signature.
  • a block signature is a digital signature made by a miner's address on other data in the block. These data include the application data packaged into the block, and can also include data in other blocks, such as timestamps, version numbers, and so on.
  • the block hash value is a value obtained by hashing data in other blocks excluding the block signature. Therefore, the application data in the signature blocks in all miners' databases are the same, but they can have different block signatures.
  • the block signature can be a digital signature made by the miner's address on the hash value of the block, or a digital signature made by the miner's address on other data in the block. Essentially, the effects of these two signatures are the same. Since the purpose of the decentralized distributed database is to ensure that the application data recorded by each node are the same, no matter which method is used to calculate the block hash value and sign the block, it does not affect the scope of application of the present invention. But obviously, the latter method is more flexible.
  • a special identifier is included in the block to distinguish the POW block from the signature block.
  • a check value is included in the block, and the POW block of a data block or the signature block is distinguished according to the positive or negative of the check value. If the check value is positive, the data The block is a POW block, and the check value is a proof of work; if the check value is negative, the data block is a signature block, and the check value is the counter value of the mining chain window.
  • the mining right chain window count value is used to record the current height of the mining right chain window (that is, the data block to which it belongs) and how many signature blocks corresponding to the current mining right chain window have been generated.
  • the computing device After the computing device receives the mining right block, it verifies the legality of the mining right block. If the mining right block is legal, the mining right block is added to the database; after the computing device receives the data block, it verifies the legality of the data block If the data block is valid, add the data block to the database.
  • the configuration of some embodiments of the present invention includes some or all of the following parameters, and the values of these parameters are either fixed or generated according to certain rules:
  • N the number of active miners
  • M the maximum number of signature blocks that a group of active miners can correspond to
  • d the basic difficulty target, used to determine whether the mining rights block has completed the proof of work; it is a constant or regular according to certain rules Adjusted value
  • D difficulty target, used to determine whether the POW block has completed the proof of work; it is a constant, or a value adjusted periodically according to certain rules, or a certain multiple of d.
  • An active miner is a miner who has the right to sign a block. That is, if the block signature is not produced by the active mine, the block signature is illegal.
  • the number of active miners is the number of miners who have the right to sign a block.
  • the mining rights chain window is used to determine the active miners, and the posts of the active miners are also the width of the mining rights chain window.
  • the transaction speed of the Bitcoin system is approximately At 7 transactions per second, it takes an average of 5 minutes for a transaction to be packaged into a block.
  • the legal mining rights block must meet the following conditions:
  • the optimal data block of the mining right block is a data block in the main data chain, and the height h of the data block is not less than the optimal data block height H of the parent mining right block;
  • the hash value of the parent mining right block is the hash value of the last mining right block in the main mining right chain.
  • blocks that do not meet this condition but meet all other legal conditions can be added to the database as sidechain blocks;
  • the mining right block has proof of work that meets the requirements.
  • FIG. 5 is an example of the optimal data block.
  • the optimal data blocks in the mining rights blocks 1-8 in the figure are data blocks 1, 2, 2, 4, 8, 10, 12, 15 respectively. .
  • the mining right block and their optimal data block are weakly consistent in context, that is, if the mining right block A is the block before the mining right area B in the mining right chain, then in the data chain, the mining right
  • the optimal data block of block A is before or the same as the optimal data block of mining right area B. Therefore, miners cannot only store and verify mining rights blocks without storing and verifying data blocks.
  • the longer the mining rights chain the longer the data chain that needs to be stored.
  • the method for verifying that the mining right block has a satisfactory workload proof is to verify that the hash value of the mining right block is less than the basic difficulty target d.
  • verifying that the mining right block has a proof of work that meets the requirements includes: determining the mining right chain window of the optimal data block P according to the optimal data block P of the mining right block Height h, if the difference between the height of the mining right block and the height h is c, c is called the waiting length, verify that the hash value of the mining right block and the value of a predetermined function f(c,d) satisfy the workload proof condition ,
  • the function f(c,d) is a function with waiting length as the argument.
  • the proof-of-work condition is a numerical less than relationship. It can also be the opposite, which is a numerical greater than relationship. Therefore, the hash value of the mining right block and the value of a predetermined function f(c,d) satisfy the workload proof condition, if the hash value of the mining right block is less than (or greater than) f(c,d).
  • the waiting length is the mining right block in the current mining right chain that has not been covered by the mining right chain window of any data block quantity.
  • These mining rights blocks will be covered by a certain mining rights chain window in the future, and the corresponding miners have the right to generate signature blocks. At present, these miners are "waiting" to obtain the right to generate signature blocks, so the number of these mining rights blocks is called the waiting length.
  • c represents the current number of miners waiting to become active miners. We do not want this value to be too low, which will cause no active miners to be available when the system fluctuates; nor do we want this value to be too high, which will cause miners to wait a long time to become active miners. Therefore, the computing device is shut down during the waiting period, which reduces the total service capacity of the system. The effect of this function is to maintain the number of miners waiting to become active miners within an ideal range by adjusting the difficulty of meeting the proof-of-work conditions.
  • the optimal data block In order to reduce the difficulty of generating mining rights blocks, miners will tend to reference the last block of the data chain in the generated mining rights blocks and store the longest possible data chain in the database, so this data block is The "optimal" is called the optimal data block.
  • One condition for judging the legitimacy of a signed block is the number of block signatures.
  • the signature block needs to contain legal block signatures made by more than half of the active miner posts to be legal. If the number of active miners is 1, the legal signature block only needs to contain one legal block signature.
  • One way to determine active miners is to use the mining rights chain window.
  • the mining right chain window of the data block is a height interval of size N in the mining right chain.
  • This interval contains N consecutive mining rights blocks in the mining rights chain, and only the block signature made by the miner's address in the mining rights block in this interval in the sub-data block of the data block is regarded as a signature block The legal block signature.
  • the miners identified by these miner addresses are active miners, and these miner addresses are active miner addresses.
  • N is not only the width of the mineral rights chain window, but also the number of active miners.
  • the optimal data block of mining right block 12 is POW block 3.
  • the active miner window of POW block 3 is [1, 3], and its height is 3.
  • the basic difficulty target d is a value that is adjusted periodically
  • the adjustment method is: setting the block production rate of a target mining right block, that is, how long a mining right block is generated. According to the actual block production rate of the mining rights block in the previous adjustment cycle, adjust the basic difficulty target d value of the next adjustment cycle to make the expected block production rate of the mining rights block in the next cycle closer to the set target mining rights area Block yield rate. Therefore, the basic difficulty target d is a value highly correlated with the mining right block.
  • the hash value of the parent data block of the data block is the hash value of the last data block of the main data chain.
  • blocks that do not meet this condition but meet all other legal conditions can be added to the database as sidechain blocks;
  • the method for verifying that the POW block has a satisfactory workload proof is to verify that the hash value of the data block is less than the difficulty target D.
  • the method for determining the difficulty target D value is as follows:
  • the last signature block before POW block 4 is signature block 2.
  • the mining right chain window of the data block is a height interval of size N [H-N+1,H], and H is called the height of the mining right chain window.
  • the mining right chain window corresponds to a group of mining right blocks within its height range in the mining right chain.
  • the interval is determined according to the following method: if the mineral rights chain window S of the parent block of the data block is [H-N+1,H], then
  • the mining right chain window of the data block is [H-N+1+m,H+m]; m is the sliding step length of the mining right chain window of the POW block; that is The mining right chain window of the data block is the mining right chain window of its parent block sliding backward m blocks;
  • the mining rights chain window of the signed block is [H-N+1+n,H+ n]; n is the sliding step length of the mining chain window of the signature block; that is, the mining chain window of the data block is the mining chain window of its parent block sliding backward n blocks;
  • the mining rights chain window of the data block is S.
  • the verification value of the signature block is the mining right window count value.
  • the check value of the data block is set according to the following rules:
  • the check value is proof of work, even if the hash value of the block satisfies the positive random number of the proof of work condition;
  • the check value is a negative number determined according to the following method, called the mining rights window count value: if the check value of the parent block of the signature block is positive or less than -M Negative number, the verification value of the signature block is -1; if the verification value of the parent block of the signature block is equal to 1-M, the verification value of the signature block is -(M+H+n); otherwise, it is signed
  • the block check value is the check value of the parent block minus 1; H is the height of the mining chain window of the parent block of the data block.
  • the block mining rights chain window of the data block can be quickly determined without tracing the entire data chain. For any data block, trace back along the data chain from the data block to the first block with a check value L less than -M, record the number of POW blocks K in the backtracking process, and the mining rights chain of the data block
  • L check value
  • the application data includes transaction data.
  • the active miner who generates the signature block is also required A certain number of tokens are provided as collateral, and these collateral tokens cannot be used for a certain period of time after the signature block is generated.
  • One of the accounting methods commonly used in the blockchain is UTXO, as used in Bitcoin. This method does not centrally record the user’s assets.
  • the user uses cryptography to unlock the transaction output to prove the ownership of the transaction output and simultaneously To spend the transaction output, the pass is the output of a transaction, and the unused pass refers to the output of a transaction that has not been cited as an input by any transaction.
  • the mining rights block further includes a set of output points.
  • the output point is a reference to the transaction output, generally including the hash value of the transaction and the serial number of the output in the transaction.
  • the transaction output includes a locking script, and the transaction output can only be used when the locking script is unlocked.
  • the lock script contains an address called the target address of the transaction output. Verifying the legitimacy of the signed block also includes:
  • Verifying the legitimacy of the mining rights block also includes:
  • the mining rights block includes the hash value of the optimal data block, as long as the mining rights block is finally confirmed, any data chain side chain whose fork point is before the optimal data block, no matter how long it is, cannot become a data chain. Main chain.
  • the final confirmation of the mining right block is also the final confirmation of the optimal data block of the mining right block.
  • the above-mentioned mortgage token method can increase the user's confidence and accept application data that has been packaged into the data chain but has not yet been finalized, and in the case of double signatures , You can use mortgages to compensate users for their losses.
  • An embodiment of the present invention is a method for adjusting the block generation rate of a signature block.
  • the data block in this embodiment also includes the timestamp when the block was generated, and verifying the legitimacy of the signed block also includes:
  • the size of the verification signature block does not exceed a certain limit, which is called the maximum signature block capacity.
  • the maximum signature block capacity is a value adjusted periodically.
  • the method of adjusting the maximum signature block capacity includes the average block production time (T) of the signature block in the last adjustment cycle, the average block size of the signature block in the last adjustment cycle (C), and the target block production time (G). ), the maximum signature block capacity of the next cycle is set to be an integral multiple of a base (for example, 4KB) close to G/T ⁇ C.
  • Another embodiment of the present invention is a method for adjusting the maximum signature block capacity, which includes the average block size (T) of the signature block in the last adjustment period and the average block size of the signature block in the last adjustment period ( C).
  • Target block production time (G). Set the maximum signature block capacity of the next cycle to an integral multiple of a base (for example, 4KB) close to G/T ⁇ C/P.
  • P is the target capacity utilization rate, which is A value between 0 and 1.
  • Another embodiment of the present invention is a method for adjusting the maximum signature block capacity, which includes adjusting according to the average block production time (T) and target block production time (G) of the signature block in the last adjustment period, if T>G ⁇ (1+r), then increase the maximum signature block capacity, if T ⁇ G ⁇ (1-r), then decrease the maximum signature block capacity.
  • r is a constant, used to control the adjusted threshold.
  • miners can charge for storing application data, miners have an incentive to pack as much application data as possible into a block. For signed blocks, since no other miners can compete for the right to produce blocks, if the block size is not limited, the miners will wait a long time to pack more application data, resulting in a longer confirmation delay.
  • the maximum signature block capacity is reduced in the next cycle; otherwise, the maximum signature block capacity is increased. Therefore, if the application data flow is roughly stable, after a few cycles, the average block production time will be close to the target block production time.
  • An embodiment of the present invention is a method for generating a mining right block by a computing device, which includes the following steps:
  • An embodiment of the present invention is a method for generating data blocks, which includes the following steps:
  • a temporary data block is a set of application data, the hash value of the parent data block is the hash value of the last data block of the main data chain, the proof of work and the block signature Pending data block;
  • the miner address of the computing device is not the active miner address of the last data block of the main data chain, and no new data block is received within the predetermined time after the last data block is received or generated, it will be based on the temporary The data block generates a POW block, adds the generated POW block to the database, and broadcasts it to the entire network;
  • the data block becomes a signature block, and the generated signature block is added to the database and broadcast to the entire network;
  • miner address of the computing device is the active miner address of the last data block of the main data chain, and N>1, then:
  • the consensus data block is a temporary data area selected from the temporary data blocks of all the above active miners Piece;
  • An embodiment of the present invention is a method for generating a POW block, which includes finding a proof of work that conforms to the proof of work through hash collision.
  • the application data includes transaction data of the database.
  • the corresponding database transaction is executed according to the database transaction data in the data block.
  • the present invention can generate traditional databases in a decentralized and distributed manner, so that the application scope of decentralized distributed databases is no longer limited to the limited scope of blockchain transaction processing, data storage, etc. , And can effectively handle the business that requires a process (thus low latency is an important factor) to complete.
  • the embodiment of the present invention is a decentralized distributed database system. As shown in Fig. 1, the system is composed of several computing devices connected to the network. The computer device is configured with a database formed based on any of the foregoing decentralized distributed database forming methods.
  • Each computing device can receive data blocks and mining rights blocks from other computing devices.
  • the computing device verifies the legality of the mining right block after receiving the mining right block, and adds the legal mining right block to the local database.
  • the computing device verifies the legality of the data block after receiving the data block, and adds the legal data block to the local database.
  • the computing device may also receive application data from the network and application data from other computing devices to generate new data blocks and new mining rights blocks.
  • the computing device finds the hash value that meets the difficulty required by the current mining rights chain state through the hash collision, generates a legal mining right block, adds the generated legal mining right block to the local database and broadcasts it to the entire network.
  • a POW block is a block containing proof of work.
  • the signature block is the block containing the signature of the active miner's block.
  • the computing device packages the application data received within a period of time to generate a candidate data block. The computing device judges whether it is an active miner according to the current status of the data link and the mining rights chain.
  • the computing device finds a hash value that meets the difficulty required by the current data chain state through hash collision, and generates a legal POW block.
  • the generated legal POW blocks are added to the local database and broadcast to the entire network.
  • the signature block needs to have the signatures of multiple active miners, that is, N>1.
  • the active miners select one of the candidate data blocks generated by the active miners as a consensus block by executing the consensus protocol, and more than half of the active miners sign the block to generate a signature block, which is added to the local database and sent to the entire network broadcast.
  • the embodiments of the present invention can be provided as a method, a system, or a computer program product. Therefore, the present invention may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
  • computer-usable storage media including but not limited to disk storage, CD-ROM, optical storage, etc.
  • These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device.
  • the device implements one or more functions specified in the process description.
  • These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment. Instructions provide steps for implementing one or more functions specified in the process description.
  • this application can be provided as methods, systems, or computer program products. Therefore, this application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, this application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
  • computer-usable storage media including but not limited to disk storage, CD-ROM, optical storage, etc.
  • These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device.
  • the device implements the functions specified in one or more steps.
  • These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment. Instructions provide steps for implementing functions specified in one or more steps.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Business, Economics & Management (AREA)
  • Finance (AREA)
  • Databases & Information Systems (AREA)
  • Accounting & Taxation (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • Development Economics (AREA)
  • Bioethics (AREA)
  • Software Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Data Mining & Analysis (AREA)
  • Computing Systems (AREA)
  • General Health & Medical Sciences (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Strategic Management (AREA)
  • Technology Law (AREA)
  • General Business, Economics & Management (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

提供了一种去中心化分布式数据库的形成方法、系统、电子设备及计算机可读存储介质,去中心化分布式数据库包含矿权链和数据链。矿权链中的区块包含矿工地址,每个矿工按矿权链中区块的顺序依次产生一定数量的数据链中的区块。数据链中的区块包含矿工签名以证明区块是由获得产块权的矿工所产生的。

Description

去中心化分布式数据库的形成方法及系统、电子设备及计算机可读存储介质 技术领域
本发明涉及去中心化分布式数据库技术领域,具体涉及一种去中心化分布式数据库的形成方法和系统,电子设备及计算机可读存储介质。
背景技术
分布式数据库是由多个通过网络相连的设备(如计算机、服务器)共同维护的数据库系统。分布式数据库可分为中心化和去中心化的二种。中心化的分布式数据库系统有一个主服务器和若干个从服务器,数据库以主服务器的记录为准。去中心化的分布式数据库系统包括多个节点,没有主服务器,所有节点地位平等,依靠共识算法维护数据库的一致性。
目前的去中心化的分布式数据库技术存在数据处理速度慢和延迟时间长的问题。去中心化的分布式数据库通过共识算法使节点之间无需知道其它记账节点的数据库所储存的数据就能达成一致,储存相同的数据,因而维护相同的数据库。常见的共识算法是工作量证明(POW),即所有的节点竞相产生新区块,新产生的区块必须提供完成了根据当前区块链状态所决定的工作量的证明才能获得添加进数据库的资格。POW算法要有效,工作量证明的难度必须足够大因而需要一定时间才能完成,以对新区块作出区分,容纳区块在网络中传播的延迟。例如在比特币网络中,工作量难度的设置是使全网大约每10分钟产生一个新区块,每个区块1MB大小,因此数据处理速度是大约每秒7笔交易,数据处理速度慢。
去中心化的分布式数据库可用于处理交易,数据存证等场景,在这些场景中,数 据存入去中心化的分布式数据库后,不会立即需要使用,因此数据处理的延迟时间长短不影响系统的效率。但在与流程有关的应用中,如工作流、供应链管理等,数据处理延迟时间长会导致系统效率的降低。例如有100笔数据需要处理,延迟时间是5秒,如果这些数据之间没有关联,可以同时处理,则处理完全部100笔数据只需要5秒。而如果这100笔数据是有前后关系的流程数据,则只能依次处理,处理完全部100笔数据需要500秒。因此延迟时间是决定系统效率的关键。而现有的去中心化的分布式数据库使用POW算法,都存在高延迟的问题。
发明内容
本发明提供一种去中心化的分布式数据库方法,旨在解决上述技术问题。
本发明还提供一种去中心化分布式数据库的形成方法,所述方法具体包括如下步骤:
接收矿权区块,验证所述矿权区块是否合法,若合法,则将合法矿权区块添加进数据库中;
接收数据区块,验证所述数据区块是否合法,若合法,则将合法数据区块添加进数据库中;
数据区块包含对另一数据区块的引用,数据区块通过引用关系组成链式数据结构,称为数据链,矿权区块包含对另一矿权区块的引用,矿权区块通过引用关系组成链式数据结构,称为矿权链;
矿权区块包含矿工地址,数据区块包括签名区块,签名区块中包含有应用数据、以及矿权链主链上矿权区块中的矿工地址对打包应用数据作出的数字签名,所述数字签名称为区块签名。
进一步的,按照矿权链主链中矿权区块的次序,以矿权区块中的矿工地址作出区块签名,每个矿工地址产生预定数量的签名区块,将所产生的签名区块依次加入 数据库并向其它计算设备广播,签名区块是指含有数字签名的数据区块。
进一步的,数据区块还包括POW区块;
接收上一数据区块后的预定时间内,若未收到新的数据区块,则对所收到的应用数据打包产生POW区块,将新产生的POW区块加入数据库,并向其它计算设备广播。
进一步的,矿权区块包含对一个数据区块的引用,矿权区块所引用的数据区块称为最优数据区块,合法矿权区块需满足如下条件:
1)所述矿权区块的最优数据区块高度h不小于其父矿权区块的最优数据区块高度H,即h≥H;
2)父矿权区块是当前矿权链主链上的最后一个矿权区块;
3)矿权区块的矿工地址不在矿权链主链的最后N-1个矿权区块中,其中,N为矿权链窗口的大小。
进一步的,合法的签名区块需满足如下条件:
1)签名区块的父数据区块是当前数据链主链的最后一个数据区块;
2)签名区块有活跃矿工员额一半以上的矿工地址作出的合法区块签名。
进一步的,所述矿工地址是签名区块父区块的矿权链窗口的矿权区块中的矿工地址。
进一步的,签名区块的矿权链窗口确定方法具体如下:
若签名区块之前的M个数据区块的矿权链窗口都相同;则所述签名区块的矿权链窗口是签名区块父区块的矿权链窗口向后滑动n个矿权区块所构成的矿权链窗口;否则,则签名区块的矿权链窗口与签名区块父区块的矿权链窗口相同,其中,n为签名区块的矿权链窗口滑动步长,M为每个矿权链窗口可对应的签名区块数量最大值。
POW区块的矿权链窗口确定方法如下:
POW区块的矿权链窗口是POW区块父区块的矿权链窗口向后滑动m个矿权区块所 构成的矿权链窗口,其中,m为POW区块的矿权链窗口滑动步长。
进一步的,合法矿权区块还需满足如下条件:
矿权区块的工作量证明满足根据等待长度的函数所确定的难度值,等待长度是矿权区块高度与所述矿权区块的最优数据区块的矿权链窗口高度之差。
进一步的,应用数据包括交易数据,矿权区块包括一组输出点,输出点是对交易输出的引用,验证矿权区块合法性还包括:
验证所述矿权区块中所有输出点所引用的都是未使用的交易输出,所述未使用交易输出的目标地址是矿权区块中的矿工地址,且所有所述未使用交易输出的价值总和不小于预先设定的值。
进一步的,合法区块签名需满足如下条件:
3)与作出区块签名的矿工地址对应的矿权区块中所有输出点所引用的都是未使用的交易输出。
进一步的,合法签名区还需满足如下条件:
4)签名区块的大小不超过周期性调整的最大签名区块容量,周期性调整方法为根据周期内签名区块平均产块时间确定下一周期的最大签名区块容量。
进一步的,应用数据包括数据库事务数据,应用数据包括数据库事务数据,根据数据链主链数据区块中的数据库事务数据执行相应的数据库事务,或者是根据合法数据区块中的数据库事务数据执行相应的数据库事务。
本发明还提供了一种去中心化分布式数据库系统,所述系统由通过网络相互通信的计算设备组成,计算机设备上配置有基于上述去中心化分布式数据库的形成方法形成的数据库。
进一步的,签名区块由N个计算设备共同产生,所产生的签名区块包括大于N/2个矿工地址所作的区块签名;矿工地址为签名区块父区块的矿权链窗口中的矿工地址。
本发明还提供一种电子设备,包括存储器,处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述程序时实现如上述的去中心化分布式数据库的形成方法。
本发明还提供一种计算机可读存储介质,所述计算机可读存储介质存储实现如上述去中心化分布式数据库形成方法的程序。
去中心化的分布式数据库为在节点之间维护数据库的一致性,每个节点都需要执行相同的共识算法。作为去中心化的分布式数据库,区块链中最常见的共识算法是工作量证明,即新区块需要提供完成了根据区块链状态所确定难度的工作量证明,只有提供了工作量证明的区块才是合法的区块。当多个节点同时提交包含不同数据的合法区块时,节点在候选链中选择最长或累计工作量最多的链为有效链。为避免区块链出现大量分岔,难度的设置必须使节点需要花费一定的时间才能产生所需要的工作量证明,这导致区块链处理数据的速度受到限制,延迟时间较长,不能满足很多应用的需要,特别时那些需要实时处理数据的应用。虽然除了交易的处理,区块链技术也可以用于储存其它类型的数据。例如利用区块链数据无法篡改的特性,区块链技术还被用于存证。但目前的区块链技术不适合用于处理流程数据,因为流程的前后环节之间存在依赖关系,区块链技术的高延迟会导致系统效率的降低。
本发明提出将产出区块权利的获得和实际产出区块的行为分开,节点以竞争性的方式获在未来得产出区块权利,当轮到节点产出区块时,节点可以产出多个区块,而不仅仅是一个区块。因此与每个工作量证明相对应的数据区块数可以是系统任意设定的,只要计算设备的性能足够强,区块产出的时间间隔、延迟时间可以任意短,数据处理可以足够高,能够满足实时应用和流程处理的需要。
在本发明中,数据库包括二个链式数据结构。其中一个称为矿权链,另一个称为数据链。矿权链中的区块记录获得记账权的矿工地址,不包含应用数据。矿权链中的区块以竞争性方式产生,需要比较长的时间才能产生一个矿权链区块。例如采 用哈希碰撞的方式,产生满足一定难度值的矿权链区块。而数据区块则根据矿权链中区块的顺序,依次由相应的矿工产生,每个矿工可以产生一批预定数量的数据区块。通过这样的方式,可以满足任意产块率的需求而不牺牲安全性。例如在交易处理中,如果需要和比特币相当的安全性,可以设置工作量证明的难度值,使平均每10分钟产生一个矿权区块。而如果需要在每10分钟产生一个矿权区块条件下达到每秒4200笔的交易速度,可以将每个矿工可以产生数据区块的数量设为600,这样在系统稳定运行时,每10分钟可以产出600个区块,数据处理速度是比特币网络的600倍,即每秒4200笔交易;平均延迟时间是0.5秒,是比特币网络的600分之一。矿工以提供对区块数字签名的方式证明该区块是由有产块权的矿工所产生的。
由于在任何时候都有一位矿工垄断了产生区块的权利,如果这时候矿工的设备发生故障就会导致长时间不能产生新的数据区块。为解决这种问题,本发明提出二种方法。一种方法就是允许有二种数据区块,分别称为签名区块和POW区块,签名区块是按上述方式根据矿权链中矿工的顺序由获得产块权的矿工依次产生。POW区块是用传统的工作量证明的方式产生的数据区块,任何节点都可以产生POW区块,不受矿权链中矿工顺序的限制,但需要比较长的时间才能产生一个区块。正常情况下,由于产生签名区块的速度远远大于产生POW区块的速度,节点所产生的POW区块根本就没有机会成为主链上的区块,因此节点不会浪费资源去产生POW区块。但节点如果超过一定时间没有收到新的数据区块,则说明有产块权的节点可能发生了故障,这时候节点就可以启动POW区块的产生。这种方法能保证系统不会因为节点故障而冻结,但性能会下降。
另一种方法就是让签名区块由一组预定数量的矿工,而不是一个矿工,共同产生,由其中过半数的矿工签名即为有效。本发明使用一种滑动矿权链窗口的方法来决定哪一组矿工可以参与产生签名区块。只要故障节点的数量少于该预定数量的一半,系统就可以稳定地产生新签名区块,性能不受影响。在故障节点的数量超过该 预定数量的一半时,系统中节点产生POW区块,系统性能受到影响,但不会冻结。然而这种影响是短暂的,因为POW区块模式会驱使矿权链窗口滑动,导致故障节点失去产块权,其它节点取得产块权。
数据区块所能储存的数据不限于交易数据,可以是任何类型的数据。特别地,数据区块中的数据可以是数据库事务数据,在数据区块成为数据链主链区块后,节点执行数据区块中数据库事务数据所对应的数据库事务。因此形成一个通用的去中心化分布式数据库。由于本发明的低延迟特性,这种通用的去中心化分布式数据库可用于工作流、供应链管理等应用。
本发明提出的方法是一种去中心化的方法,因为任何节点都可以通过竞争产生矿权区块的方式最终获得产生数据区块的权利。本发明中数据库的安全性与处理速度是脱钩的。使用本发明可以在不牺牲安全性的情况下达到很高的处理速度,或在不降低处理速度的情况下提高安全性,甚至可以同时达到很高的安全性和很高的处理速度。
附图说明
图1为本发明的一个分布式数据库实施例的全局示意图;
图2为本发明实施例的计算设备示意图;
图3为本发明实施例的矿权链示意图,其中(a)为矿权链的链式数据结构,(b)为矿权链的分支式的数据结构;
图4为本发明实施例的数据链示意图,其中(a)为数据链的链式数据结构,(b)为数据链的分支式的数据结构;
图5为本发明实施例的矿权链引用数据链关系示意图;
图6为本发明实施例的矿权链窗口示意图;
图7为本发明实施例的难度值示意图。
具体实施方式
基于本发明的原理可以有多种实施例。下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述。显然,所描述的实施例仅是本发明的一部分实施例,而不是全部实施例。基于本发明中的实施例或原理,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本发明保护的范围。
本发明的一些实施例是在通过网络相互通讯的一组计算设备上形成分布式数据库的方法。如图1所示,多个计算设备通过网络相互通讯,每个计算设备都包括处理器和存储器,存储器中的储存有数据库。对于分布式数据库中的任何一项有效数据,计算设备通过执行本发明所述的方法,所有计算设备最终都会储存相同的有效信息。
如图2所示,计算设备包括数据库,储存该数据库的存储单元,和处理单元,并配置有通信模块,可以接受来自其他计算设备的矿权区块、数据区块及应用数据。应用数据是与应用场景相关的数据,例如区块链的交易数据,数据库事务数据,存证数据,公司业务数据,人事档案数据,及任何传统数据库所保存和处理的数据都属于本发明所称的应用数据。
计算设备可以是单独的一台计算机或服务器;也可以是一组计算机或服务器,其中每一台计算机或服务器只执行本发明中的部分方法,承担部分功能,而合起来执行本发明中的完整的方法,承担完整的功能。另一方面,通过虚拟化技术,物理上的一台计算机或服务器可以在网络中呈现为多个计算机或服务器,这种情况下物理上的一台计算机或服务器应当视为是本发明中的多个计算设备,而不仅仅是一个计算设备。
每个计算设备都配置一对公钥和私钥,根据公钥又可以产生一个地址,所产生的 地址称为矿工地址。一般来说矿工地址是公钥本身,或者是公钥的哈希值。在密码学中,公钥和私钥是一对有数学关系的数,但又无法根据公钥计算出私钥。私钥不对外公开,仅由私钥所有者保管,用于对数据签名。一般是先对需要签名的数据产生一个摘要,然后用私钥对摘要进行加密,加密的结果即为数字签名。验证数字签名包括用公钥去解密数字签名,如果解密成功则说明加密所用的是与该公钥相关联的私钥。然后根据公钥去产生地址,若地址与数字签名提供者的地址相同,则认为该数字签名是真实的。在本发明中,上述地址称为矿工地址,如此而作的数字签名称为是该矿工地址作出的数字签名。
数据库中的数据包括由二种区块组成的二种链式数据结构。这二种区块分别为矿权区块和数据区块。
每个矿权区块包含对另一矿权区块的引用,被引用的矿权区块称为该矿权区块的父区块或父矿权区块;该矿权区块称为该父区块的子区块。本实施例中,矿权区块以在区块数据中包括前一矿权区块哈希值的方式引用父区块。数据库中的所有矿权区块通过他们的父区块哈希值形成一如图3(a)所示的链式数据结构,称为矿权链。
每个数据区块包含对另一数据区块的引用,被引用的数据区块称为该数据区块的父区块或父数据区块;该数据区块称为该父区块的子区块。本实施例中,数据区块以在区块数据中包括前一数据区块哈希值的方式引用父区块。数据库中的所有数据区块通过他们的父区块哈希值形成一如图4(a)所示的链式数据结构,称为数据链。
每个矿权区块包括以下数据,见表1:
表1矿权区块包括的数据
名称 内容
父矿权区块哈希值 前一矿权区块的哈希值
矿工地址 根据公钥产生的一个地址
最优数据区块哈希值 一个数据区块的哈希值
工作量证明 一个随机数,用于影响矿权区块哈希值的产生
矿工是源于区块链技术的一个概念,在区块链中,矿工是指参与竞争产生区块的计算设备。本发明中也称计算设备称为矿工或节点。矿工配置有一对公钥和私钥。矿工以一个矿工地址来标识,其它矿工通过验证与该矿工地址相应的数字签名来确认其资格、身份、或权利。矿工和物理上的设备并不一定是一一对应的。在区块链技术中,可以把一组物理上的设备组织起来形成一个矿池,共同协作产生区块,挖矿收益归属于一个矿工地址,而在矿池内部进一步分配所得收益。矿池可以视为一个矿工。在本发明中,还可以有其它物理上的设备的配置方式,例如配置二个计算机或服务器,其中一个专门产生矿权区块,在其所产生的矿权区块中矿工地址都是某一地址;而第二个专门产生数据区块,其所产生的签名区块都以该矿工地址作出区块签名。这二个计算机或服务器组成一个矿工。计算设备、矿工或节点是同义词,可以定义为配置有一对公钥和私钥,以一个矿工地址为标识,具有数据储存、处理和网络通讯能力的设备。
最优数据区块是数据链中一个数据区块。矿工可以在一定范围内任意选择。矿工一般选择数据链主链中最后的数据区块为最优数据区块。矿工也可以选择父矿权区块的最优数据区块或在其之后的任一数据区块为子矿权区块的最优数据区块。
在有些实施例中,数据库中允许多个有相同父矿权区块哈希值的矿权区块存在,因而形成如图3(b)带分支的数据结构,在这种情况下,最长或累计工作量最多的分支为有效链,称为主矿权链或矿权链主链,其它分支为无效数据,称为侧矿权链或矿权链侧链;当一条侧矿权链因为增加了矿权区块变成最长或累计工作量最多的分支时,矿工对数据库中的数据进行重组,使该侧矿权链成为新的主矿权链,而原来的主矿权链成为侧矿权链。为统一名称,即使在不允许侧链的实施例中,数据库中只有一个矿权链,我们也称此矿权链为主矿权链或矿权链主链。
在有些实施例中,数据库中允许多个有相同父数据区块哈希值的数据区块存在, 因而形成如图4(b)带分支的数据结构,在这种情况下,最长的分支为有效链,称为主数据链或数据链主链,其它分支为无效数据,称为侧数据链或数据链侧链。侧数据链又存在二种类型,一种是分岔点在矿权链尾矿权区块的最优数据区块之后(含),一种是分岔点在矿权链尾矿权区块的最优数据区块之前。当一条第一种类型的侧数据链因为增加了数据区块变成最长或累计工作量最多的分支时,矿工对数据库中的数据进行重组,使该侧数据链成为新的主数据链,而原来的主数据链成为侧数据链。为统一名称,即使在不允许侧链的实施例中,数据库中只有一个数据链,我们也称此矿权链为主数据链或数据链主链。
数据区块又包括二种:POW区块和签名区块。所有数据区块都包含打包的应用数据和父数据区块的区块哈希值。除此之外,POW区块还包含工作量证明,签名区块还包含区块签名。
在有些实施例中,区块哈希值是对包括区块签名在内的区块中的数据进行哈希运算所得的值。因此所有矿工的数据库中的签名区块不仅有相同的应用数据,也有相同的区块签名。区块签名是矿工地址对区块中其它数据作出的数字签名,这些数据包括打包进区块的应用数据,还可以包括其它区块内的数据,例如时间戳、版本号等等。
在另一些实施例中,区块哈希值是对不包括区块签名在内的其它区块中的数据进行哈希运算所得的值。因此所有矿工的数据库中的签名区块中的应用数据都相同,但它们可以有不同的区块签名。区块签名可以是矿工地址对区块哈希值作出的数字签名,也可以是矿工地址对区块中其它数据作出的数字签名。本质上这二种签名的效果是相同的。由于去中心化分布式数据库的目的在于确保各节点所记录的应用数据都相同,因此无论采用哪种方式计算区块哈希值和作区块签名都不影响本发明的适用范围。但显然,后一种方式更具灵活性。
在一些实施例中以在区块中包括专门的标识来区别POW区块和签名区块。在另一 些实施例中以在区块中包含一校验值,根据校验值的正负性来区别一个数据区块的POW区块还是签名区块,如果校验值为正数,则数据区块为POW区块,校验值为工作量证明;如果校验值为负数,则数据区块为签名区块,校验值为矿权链窗口计数值。矿权链窗口计数值用于记录当前(即所属数据区块的)矿权链窗口的高度和已经产生了多少个与当前矿权链窗口相对应的签名区块。
计算设备收到矿权区块后,验证矿权区块的合法性,若矿权区块合法,将矿权区块添加进数据库;计算设备收到数据区块后,验证数据区块的合法性,若数据区块合法,将数据区块添加进数据库。
本发明一些实施例的配置包括以下部分或全部参数,这些参数的值或者是固定的,或者是根据一定规则产生的:
N:活跃矿工员额;M:一组活跃矿工可对应的签名区块的最大数量;d:基础难度目标,用于判定矿权区块是否完成了工作量证明;为一常数或根据一定规则定期调整的数值;D:难度目标,用于判定POW区块是否完成了工作量证明;为一常数,或根据一定规则定期调整的数值,或d的某个倍数值。
活跃矿工是有权作出区块签名的矿工。即若区块签名不是活跃矿工作出的,则区块签名不合法。活跃矿工员额是有权作出区块签名的矿工数量。有的实施例中使用矿权链窗口确定活跃矿工,则活跃矿工的员额也是矿权链窗口宽度。通过调整上述参数,一个分布式数据库系统可以安全地实现高处理速度和低延迟。例如在比特币系统中,定期调整工作量证明难度使系统大约每10分钟产生一个区块,每个区块不超过1MB大小(约含4000个交易),因此比特币系统处理交易的速度大约是每秒7笔,交易平均需要等待5分钟才能被打包进一个区块。而使用本发明的方法,为达到与比特币同等的安全性,可以设置基础难度目标d使系统大约每10分钟产生一个矿权区块,但另一方面设置M=600,因此每个获得产生交易区块权利的矿工可以产生600个数据区块。再设置区块最大容量与计算设备每秒能处理的交易数量相匹配,则 矿工在10分钟内可以产生600个数据区块,交易平均只需等待0.5秒就能被打包进一个数据区块。由于不关联的交易可以由多个处理器或计算机并行处理,矿工处理交易的速度只受限于网络传播的速度,如果网络传播速度是1MB/s,则矿工每秒可以处理大约4000笔交易。因此无论是处理速度还是延迟都远远优于比特币系统。
合法矿权区块需满足如下条件:
1)矿权区块的最优数据区块是主数据链中的一个数据区块,且该数据区块的高度h不小于父矿权区块的最优数据区块高度H;
2)父矿权区块哈希值是主矿权链最后一个矿权区块的哈希值。在允许侧链的数据库中,不符合此条件但符合全部其他合法性条件的区块可以作为侧链的区块添加进数据库之中;
3)矿权区块的矿工地址不在主矿权链的最后N-1个矿权区块中;
4)矿权区块有符合要求的工作量证明。
图5是一个关于最优数据区块的实施例,图中矿权区块1~8中的最优数据区块分别是数据区块1,2,2,4,8,10,12,15。矿权区块与它们的最优数据区块在前后关系上是弱一致的,即如果矿权区块A是矿权链中矿权区B之前的区块,则在数据链中,矿权区块A的最优数据区块在矿权区B的最优数据区块之前或相同。因此矿工不能只储存和验证矿权区块而不储存和验证数据区块,矿权链越长,所需要储存的数据链也越长。
在本发明的一些实施例中,验证矿权区块有符合要求的工作量证明的方法是验证矿权区块的哈希值小于基础难度目标d。在本发明的另一些实施例中,验证矿权区块有符合要求的工作量证明包括:根据矿权区块的最优数据区块P,确定最优数据区块P的矿权链窗口的高度h,若矿权区块的高度与高度h之差为c,c称为等待长度,验证矿权区块的哈希值与一预定函数f(c,d)的值满足工作量证明条件,函数f(c,d)是以等待长度为自变量的函数。
一般地,工作量证明条件是一个数值上的小于关系。也可以相反,是数值上的大于关系。因此矿权区块的哈希值与一预定函数f(c,d)的值满足工作量证明条件,若矿权区块的哈希值小于(或大于)f(c,d)。
如果矿权区块的最优数据区块总是当前数据链的最后一个数据区块,则等待长度是当前矿权链中尚未被任何数据区块的矿权链窗口所覆盖的矿权区块数量。这些矿权区块在未来会被某个矿权链窗口所覆盖,相应的矿工获得产生签名区块的权利。而在目前,这些矿工在“等待”获得产生签名区块的权利,因此这些矿权区块的数量称为等待长度。在本发明的另一些实施例中,f(c,d)是这样的函数:如果等待长度c≤C,则f(c,d)=d;否则f(c,d)=d×g (c-C)。C,g为常数。
c代表了当前等待成为活跃矿工的矿工数量,既不希望该值过低,导致系统出现波动时没有活跃矿工可用;也不希望该值过高,导致矿工因为需要等待很长时间才能成为活跃矿工,因此在等待期内关闭计算设备,使系统总服务能力降低。而该函数的效果是通过调节满足工作量证明条件的难度使等待成为活跃矿工的矿工数量维持在一理想的范围。
矿工为了降低产生矿权区块的难度,会倾向于在所产生的矿权区块中引用数据链的最后一个区块,并在数据库中储存尽可能长的数据链,因此这个数据区块是“最优”的,故称为最优数据区块。判定签名区块合法性的一个条件是区块签名的数量。签名区块需要包含活跃矿工员额一半以上的矿工地址作出的合法区块签名才是合法的。若活跃矿工员额为1,合法的签名区块只需要包含一个合法区块签名。确定活跃矿工的一个方法是使用矿权链窗口。数据区块的矿权链窗口是矿权链中一个大小为N的高度区间,该区间的上限称为矿权链窗口的高度,下限称为矿权链窗口的底。该区间包含矿权链中连续N个矿权区块,只有该区间内矿权区块中的矿工地址在该数据区块的子数据区块中作出的区块签名才被认为是签名区块的合法区块签名。这些矿工地址所标识的矿工为活跃矿工,这些矿工地址为活跃矿工地址。N既是矿权链窗 口的宽度,也是活跃矿工员额。
如图7所示,矿权区块12的最优数据区块是POW区块3,POW区块3的活跃矿工窗口是[1,3],其高度是3。矿权区块12的高度是12,因此c=12-3=9。如果C=6,g=1/2,则矿权区块12的难度目标是d×(1/2) (9-6)=d/8。即矿权区块12的哈希值必须小于d/8才能判定为合法。因此当矿权链的长度“领先”数据链超出一定数量时,产生矿权区块所需要得时间更长,因此保持矿权链和数据链得相对平衡。
在本发明的另一些实施例中,基础难度目标d是一个定期调整的值,调整方法是:设定一个目标矿权区块的产块率,即多长时间产生一个矿权区块。根据上一调整周期矿权区块的实际产块率,调整下一调整周期的基础难度目标d值,使在下一周期矿权区块的预期产块率更接近所设定的目标矿权区块的产块率。因此基础难度目标d是一个与矿权区块的高度相关的值。
若每一项矿权区块合法性验证的结果均为是,则判定矿权区块合法,合法数据区块需满足如下条件:
1)数据区块的父数据区块哈希值为主数据链最后一个数据区块的哈希值。在允许侧链的数据库中,不符合此条件但符合全部其他合法性条件的区块可以作为侧链的区块添加进数据库之中;
2)若数据区块是POW区块,则验证数据区块有符合要求的工作量证明;若数据区块是签名区块,则验证签名区块有多于N/2(不含N/2)个父数据区块的活跃矿工地址作出的区块签名;
在本发明的一些实施例中,验证POW区块有符合要求的工作量证明的方法是验证数据区块的哈希值小于难度目标D。在本发明的一些实施例中,确定难度目标D值的方法如下:
找到该POW区块之前的第一个签名区块,确定该签名区块的矿权链窗口的高度h,难度目标D值为矿权链在高度h的基础难度目标d的一个r倍数,即:D=d×r。 在另一实施例中,确定该签名区块的矿权链窗口的底b,难度目标D值为矿权链在底b的基础难度目标d的一个r倍数,即:D=d×r。
如图7所示,POW区块4之前的最后一个签名区块是签名区块2,签名区块2的矿权链窗口是[0,2],其高度是2。如果在该高度矿权链的基础难度目标是d,倍数r=1/4,则对于POW区块4,难度目标就是D=d/4。POW区块4的哈希值若小于d/4才可能是合法的。
数据区块的矿权链窗口是大小为N的一个高度区间[H–N+1,H],H称为矿权链窗口的高度。矿权链窗口对应于矿权链中在其高度区间内的一组矿权区块。在本发明的一些实施例中,该区间是按以下方法确定的:若数据区块的父区块的矿权链窗口S是[H–N+1,H],则
1)若数据区块是POW区块,则数据区块的矿权链窗口是[H-N+1+m,H+m];m为POW区块的矿权链窗口滑动步长;即数据区块的矿权链窗口是其父区块的矿权链窗口向后滑动m个区块;
2)若数据区块是签名区块,若签名区块之前的连续M个数据区块的链窗口都是S,签名区块的矿权链窗口是[H-N+1+n,H+n];n为签名区块的矿权链窗口滑动步长;即数据区块的矿权链窗口是其父区块的矿权链窗口向后滑动n个区块;
3)其它情况下,数据区块的矿权链窗口是S。
在一些实施例中,签名区块的校验值为矿权窗口计数值。数据区块的校验值按如下规则设定:
1)若数据区块是POW区块,校验值是工作量证明,即使区块哈希值满足工作量证明条件的正随机数;
2)若数据区块是签名区块,校验值是一按以下方法确定的负数,称为矿权窗口计数值:若签名区块父区块的校验值为正数或小于-M的负数,该签名区块的校验值为-1;若签名区块父区块的校验值等于1-M,该签名区块的校验值为-(M+H+n); 否则签名区块校验值为父区块的校验值减1;H是数据区块父区块的矿权链窗口高度。
采用这种方式,无需追溯全部数据链就可以快速地确定数据区块的区块矿权链窗口。对于任何数据区块,从该数据区块开始沿数据链回溯至第一个校验值L小于-M的区块,记录回溯过程中的POW区块数K,该数据区块的矿权链窗口高度就是:
M–L+m×K。
如图6所示,m=2,n=1,N=3,M=3,数据区块1和数据区块2都是签名区块,它们的矿权链窗口都是[1,3];数据区块3是POW区块,其矿权链窗口是[3,5];数据区块4和数据区块5都是签名区块,它们的矿权链窗口都是[3,5];数据区块5、6、7都是签名区块,它们的矿权链窗口都是[4,6];数据区块8是POW区块,其矿权链窗口是[6,8];数据区块9是签名区块,它的矿权链窗口是[6,8]。
在本发明的一些实施例中,应用数据包括交易数据,为了增加安全性,防止活跃矿工在同样的高度对二个包含不同数据的区块作区块签名,还要求产生签名区块的活跃矿工提供一定数量的通证为抵押,这些抵押通证在签名区块产生后一定时间内不能使用。区块链中常采用的一种记账方式是UTXO,如比特币中所使用的,这种方法不集中记录用户的资产,用户以密码学解锁交易输出的方式证明对该交易输出的所有权同时并花费该交易输出,通证就是一个交易的输出,未使用的通证指的就是未被任何交易引用为输入的某个交易的输出。在本发明以UTXO方式记录交易的一些实施例中,矿权区块还包括一组输出点。输出点是对交易输出的引用,一般包括交易的哈希值和输出在交易中的序号。交易输出包括一个锁定脚本,只有当锁定脚本被解锁时,交易输出才能使用。锁定脚本中包含一个地址,称为交易输出的目标地址。验证签名区块的合法性还包括:
验证作出区块签名的每个矿工地址对应的矿权区块中所有输出点所引用的都是未使用的交易输出;如果有任何一个区块签名,其对应的矿权区块中有一个输出点所引用的交易输出已使用,则判定该区块签名不合法。
验证矿权区块的合法性还包括:
1.验证该矿权区块中所有输出点是否都是未被使用的交易输出;如果结果为否,则判定该矿权区块不合法;
2.验证这些交易输出的目标地址都是该矿权区块中的矿工地址;如果任何一个交易输出的目标地址不是该矿工地址,则判定该矿权区块不合法;
3.验证这些交易输出的价值总和不小于一预定值,若否,则判定该矿权区块不合法。
需要说明的是,根据本发明的方法,即使不采用上述抵押通证的方法也足以保证安全性。因为矿权区块包括最优数据区块哈希值,只要矿权区块被最终确认,任何分叉点在最优数据区块之前的数据链侧链,无论怎样长都不可能成为数据链主链。矿权区块的最终确认也是矿权区块的最优数据区块的最终确认。
但是最终确认是需要一定时间的,对于希望即时处理的应用数据,上述抵押通证的方法可以增加用户的信心,接受已经打包进数据链但尚未被最终确认的应用数据,而在出现双重签名时,可以用抵押赔偿用户的损失。
本发明的一个实施例是调节签名区块产块率的方法。该实施例中数据区块还包括该区块产生时的时间戳,验证签名区块的合法性还包括:
验证签名区块的大小不超过一定的限度,该限度称为最大签名区块容量。最大签名区块容量为一定期调整的值。调整最大签名区块容量的方法包括根据上一调整周期内签名区块的平均产块时间(T)、上一调整周期内签名区块的平均区块大小(C)、目标产块时间(G),将下一周期的最大签名区块容量设为接近G/T×C的一个基数(例如4KB)的整倍数。
本发明的另一个实施例是调整最大签名区块容量的方法,包括根据上一调整周期内签名区块的平均产块时间(T)、上一调整周期内签名区块的平均区块大小(C)、目标产块时间(G),将下一周期的最大签名区块容量设为接近G/T×C/P的 一个基数(例如4KB)的整倍数,P为容量目标利用率,为0到1之间的数值。
本发明的另一个实施例是调整最大签名区块容量的方法,包括根据上一调整周期内签名区块的平均产块时间(T)、目标产块时间(G)进行调整,若T>G×(1+r),则增加最大签名区块容量,若T<G×(1-r),则减少最大签名区块容量。r为一常数,用于控制调整的阈值。
因为矿工可以对储存应用数据收费,因此矿工有将尽可能多的应用数据打包进一个区块的动机。对于签名区块而言,由于没有其它矿工可以竞争产块的权利,若不限制区块大小,矿工会等待长时间以打包更多应用数据,导致确认的延迟时间变长。采用上述方法,若一个周期内平均产块时间大于目标产块时间,则在下一周期中减少最大签名区块容量;反之则增加最大签名区块容量。因此若应用数据流量大致稳定,则经过若干周期后,平均产块时间将接近目标产块时间。
本发明的一个实施例是计算设备产生矿权区块的方法,包括以下步骤:
1.确定数据链最后一个数据区块的矿权链窗口的高度h;
2.验证矿权链最后N-1个矿权区块中没有计算设备的矿工地址;
3.构造矿权区块,矿权区块包括的数据见表2:
表2矿权区块包括的数据
Figure PCTCN2021090112-appb-000001
4.将所产生的矿权区块添加进数据库并向全网广播。
本发明的一个实施例是产生数据区块的方法,包括以下步骤:
1.确定主数据链最后一个数据区块的矿权链窗口;
2.产生一临时数据区块;临时数据区块是一个包含一组应用数据,其父数据区块哈希值为主数据链最后一个数据区块的哈希值,工作量证明和区块签名待定的数据区块;
3.若计算设备的矿工地址不是主数据链最后一个数据区块的活跃矿工地址,且在上次收到或产生数据区块后的预定时间内没有收到新的数据区块,则根据临时数据区块产生一POW区块,将所产生的POW区块添加进数据库,并向全网广播;
4.若计算设备的矿工地址是主数据链最后一个数据区块的活跃矿工地址,且N=1,以计算设备的矿工地址对临时数据区块作区块签名,将区块签名添加进临时数据区块成为签名区块,将所产生的签名区块添加进数据库,并向全网广播;
5.若计算设备的矿工地址是主数据链最后一个数据区块的活跃矿工地址,且N>1,则:
a)执行共识算法,与主数据链最后一个数据区块的其他活跃矿工共同决定一共识数据区块,共识数据区块是从所有上述活跃矿工的临时数据区块中选择出来的一个临时数据区块;
b)以矿工地址对共识数据区块作区块签名,将区块签名添加进共识数据区块并发送给其他活跃矿工;
c)接收来自其他上述活跃矿工对共识数据区块的区块签名,并添加进共识数据区块;当共识数据区块中签名总数超过N/2时,共识数据区块成为签名区块,将所产生的签名区块添加进数据库,并向全网广播。
有多种成熟的算法可作为实现本发明所需的与其他活跃矿工共同决定一共识数据区块的方法,如Paxos算法,拜占庭将军算法等等。
本发明的一个实施例是产生POW区块的方法,包括通过哈希碰撞找到符合工作量证明的工作量证明。
在本发明的另一个实施例中,应用数据包括数据库的事务数据,当一个新的数据区块被添加进数据链主链,根据数据区块中的数据库事务数据执行相应的数据库事务。通过这种方式,本发明可以以去中心化分布式的方式产生传统的数据库,从而使去中心化分布式数据库的应用范围不再局限于区块链的交易处理、数据存证等有限的范围,而可以有效处理需要一个流程(因而低延迟是一个重要因素)才能完成的业务。
本发明的实施例是一个去中心化分布式数据库系统,如图1所示,系统由若干个连接到网络的计算设备所组成。计算机设备上配置有基于前述任一去中心化分布式数据库形成方法所形成的数据库。
每个计算设备都可以接收来自其它计算设备数据区块、矿权区块。计算设备收到矿权区块后验证矿权区块的合法性,将合法的矿权区块添加进本地数据库。计算设备收到数据区块后验证数据区块的合法性,将合法的数据区块添加进本地数据库。
可选地,计算设备还可以接收来自网络的应用数据和来自其它计算设备的应用数据,产生新数据区块和新矿权区块。计算设备通过哈希碰撞找到符合当前矿权链状态所要求难度的哈希值,产生合法的矿权区块,将所产生的合法矿权区块加入本地数据库并向全网广播。数据区块有二种,一种为POW区块,一种为签名区块。POW区块是包含工作量证明的区块。签名区块是包含活跃矿工区块签名的区块。计算设备将一段时间内收到的应用数据打包产生一个备选数据区块。计算设备根据当前数据链和矿权链的状态判断自身是否为活跃矿工。若计算设备不是活跃矿工且在一预定的时长内没有收到新的数据区块,计算设备通过哈希碰撞找到符合当前数据链状态所要求难度的哈希值,产生合法的POW区块,将所产生的合法POW区块加入本地数据库并向全网广播。
在本发明的一个实施例中,签名区块只需要一个活跃矿工的签名,即N=1。若计算设备是活跃矿工,节点将所收到的应用数据打包产生备选数据区块,对于备选数 据区块作区块签名,产生合法的签名区块。将所产生的合法签名区块加入本地数据库并向全网广播。
在本发明的另一个实施例中,签名区块需要有多个活跃矿工的签名,即N>1。活跃矿工之间通过执行共识协议在活跃矿工所产生的备选数据区块中选择一个作为共识区块,由半数以上活跃矿工对其作区块签名产生签名区块,加入本地数据库并向全网广播。
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程说明(包括流程图、方框图、文字说明)来描述的。应理解可由计算机程序指令实现流程说明中的每一流程。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程中一项或多项指定的功能的装置。这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程说明中的一项或多项指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程说明中一项或多项指定的功能的步骤。
以上所述仅为本发明的优选实施例而已,并不用于限制本发明,对于本领域的技术人员来说,本发明实施例可以有各种更改和变化。凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。
本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的步骤来描述的。应理解可由计算机程序指令实现的每一步骤。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在一个或多个步骤中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在一个或多个步骤中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在一个或多个步骤中指定的功能的步骤。
最后应当说明的是:以上实施例仅用以说明本发明的技术方案而非对其限制,尽管参照上述实施例对本发明进行了详细的说明,所属领域的普通技术人员应当理解:依然可以对本发明的具体实施方式进行修改或者等同替换,而未脱离本发明精神和范围的任何修改或者等同替换,其均应涵盖在本发明的权利要求保护范围之内。

Claims (16)

  1. 一种去中心化分布式数据库的形成方法,其特征在于,所述方法具体包括如下步骤:
    接收矿权区块,验证所述矿权区块是否合法,若合法,则将合法矿权区块添加进数据库中;
    接收数据区块,验证所述数据区块是否合法,若合法,则将合法数据区块添加进数据库中;
    数据区块包含对另一数据区块的引用,数据区通过引用关系组成链式数据结构,称为数据链,矿权区块包含对另一矿权区块的引用,矿权区块通过引用关系组成链式数据结构,称为矿权链;
    矿权区块包含矿工地址,数据区块包括签名区块,签名区块中包含有应用数据、以及矿权链主链上矿权区块中的矿工地址对打包应用数据作出的数字签名,所述数字签名称为区块签名。
  2. 根据权利要求1所述去中心化分布式数据库的形成方法,其特征在于,按照矿权链主链中矿权区块的次序,以矿权区块中的矿工地址作出区块签名,每个矿工地址产生预定数量的签名区块,将所产生的签名区块依次加入数据库并向其它计算设备广播,签名区块是指含有区块签名的数据区块。
  3. 根据权利要求1所述去中心化分布式数据库的形成方法,其特征在于,数据区块还包括POW区块;
    接收上一数据区块后的预定时间内,若未收到新的数据区块,则对所收到的应用数据打包产生POW区块,将新产生的POW区块加入数据库,并向其它计算设备广播。
  4. 根据权利要求1所述去中心化分布式数据库的形成方法,其特征在于,矿权区块包含对一个数据区块的引用,矿权区块所引用的数据区块称为最优数据区块, 合法矿权区块需满足如下条件:
    所述矿权区块的最优数据区块高度h不小于其父矿权区块的最优数据区块高度H,即h≥H。
  5. 根据权利要求1所述去中心化分布式数据库的形成方法,其特征在于,合法的签名区块需满足如下条件:
    签名区块有活跃矿工员额一半以上的矿工地址作出的合法区块签名。
  6. 根据权利要求5所述去中心化分布式数据库的形成方法,其特征在于,所述矿工地址是签名区块父区块的矿权链窗口的矿权区块中的矿工地址。
  7. 根据权利要求6所述去中心化分布式数据库的形成方法,其特征在于,签名区块的矿权链窗口确定方法具体如下:
    若签名区块之前的M个数据区块的矿权链窗口都相同;则所述签名区块的矿权链窗口是签名区块父区块的矿权链窗口向后滑动n个矿权区块所构成的矿权链窗口;否则,则签名区块的矿权链窗口与签名区块父区块的矿权链窗口相同,其中,n为签名区块的矿权链窗口滑动步长,M为每个矿权链窗口可对应的签名区块数量最大值。
  8. 根据权利要求4所述去中心化分布式数据库的形成方法,其特征在于,合法矿权区块还需满足如下条件:
    矿权区块的工作量证明满足根据等待长度的函数所确定的难度值,等待长度是矿权区块高度与所述矿权区块的最优数据区块的矿权链窗口高度之差。
  9. 根据权利要求1所述去中心化分布式数据库的形成方法,其特征在于,应用数据包括交易数据,矿权区块包括一组输出点,输出点是对交易输出的引用,验证矿权区块合法性还包括:
    验证所述矿权区块中所有输出点所引用的都是未使用的交易输出,所述未使用交易输出的目标地址是矿权区块中的矿工地址,且所有所述未使用交易输出的价值总和不小于预先设定的值。
  10. 根据权利要求9所述去中心化分布式数据库的形成方法,其特征在于,合法区块签名需满足如下条件:
    与区块签名的矿工地址对应的矿权区块中所有输出点所引用的都是未使用的交易输出。
  11. 根据权利要求1所述去中心化分布式数据库的形成方法,其特征在于,合法签名区还需满足如下条件:
    签名区块的大小不超过周期性调整的最大签名区块容量,周期性调整方法为根据周期内签名区块平均产块时间确定下一周期的最大签名区块容量。
  12. 根据权利要求1所述去中心化分布式数据库的形成方法,其特征在于,应用数据包括数据库事务数据,根据数据链主链数据区块中的数据库事务数据执行相应的数据库事务,或者是根据合法数据区块中的数据库事务数据执行相应的数据库事务。
  13. 一种去中心化分布式数据库系统,所述系统由通过网络相互通信的计算设备组成,其特征在于,计算机设备上配置有基于权利要求1至12任一权利要求所述去中心化分布式数据库的形成方法形成的数据库。
  14. 如权利要求13所述去中心化分布式数据库系统,其特征在于,签名区块由N个计算设备共同产生,所产生的签名区块包括大于N/2个矿工地址所作的区块签名,矿工地址为签名区块父区块的矿权链窗口中的矿工地址。
  15. 一种电子设备,包括存储器,处理器及存储在存储器上并可在处理器上运行的计算机程序,其特征在于,所述处理器执行所述程序时实现如权利要求1-12任意一项所述的去中心化分布式数据库的形成方法。
  16. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储实现如权利要求1至12所述去中心化分布式数据库形成方法的程序。
PCT/CN2021/090112 2020-05-11 2021-04-27 去中心化分布式数据库的形成方法及系统、电子设备及计算机可读存储介质 WO2021227867A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010396756.8A CN111611311B (zh) 2020-05-11 2020-05-11 去中心化分布式数据库的形成方法及系统、电子设备及计算机可读存储介质
CN202010396756.8 2020-05-11

Publications (1)

Publication Number Publication Date
WO2021227867A1 true WO2021227867A1 (zh) 2021-11-18

Family

ID=72200206

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/090112 WO2021227867A1 (zh) 2020-05-11 2021-04-27 去中心化分布式数据库的形成方法及系统、电子设备及计算机可读存储介质

Country Status (2)

Country Link
CN (1) CN111611311B (zh)
WO (1) WO2021227867A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114219489A (zh) * 2021-12-24 2022-03-22 中远海运科技股份有限公司 一种实时上传交易信息的区块链存证方法

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111611311B (zh) * 2020-05-11 2023-09-08 徐皓 去中心化分布式数据库的形成方法及系统、电子设备及计算机可读存储介质

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109039646A (zh) * 2018-07-12 2018-12-18 北京链享未来科技有限公司 一种基于节点能力的区块链区块打包和验证方法及系统
CN109804374A (zh) * 2016-10-20 2019-05-24 索尼公司 基于区块链的数字权限管理
CN110457926A (zh) * 2019-08-13 2019-11-15 重庆邮电大学 一种工业物联网中基于数据加密存储的数据共享方法
CN110490602A (zh) * 2018-05-09 2019-11-22 厦门本能管家科技有限公司 一种三层区块链架构构建方法及系统
US20190379546A1 (en) * 2018-06-12 2019-12-12 Chunghwa Telecom Co., Ltd. Method for reaching consensus on public distributed ledgers and system using the same
CN110705973A (zh) * 2018-07-10 2020-01-17 深圳市红砖坊技术有限公司 应用于区块链系统中矿工节点的共识方法和区块链系统
CN110730225A (zh) * 2019-09-30 2020-01-24 北京中电拓方科技股份有限公司 基于区块链的物联网的数据处理方法、物联网及存储介质
CN111611311A (zh) * 2020-05-11 2020-09-01 芜湖明轩科技有限公司 去中心化分布式数据库的形成方法及系统、电子设备及计算机可读存储介质

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10291627B2 (en) * 2016-10-17 2019-05-14 Arm Ltd. Blockchain mining using trusted nodes
US20190370793A1 (en) * 2018-06-04 2019-12-05 Decentralized Finance Labs, Inc. Hybrid consensus for blockchain using proof of work and proof of stake
CN109508987B (zh) * 2018-12-06 2021-09-17 广东浪潮大数据研究有限公司 一种区块链的构建方法、系统及相关组件

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109804374A (zh) * 2016-10-20 2019-05-24 索尼公司 基于区块链的数字权限管理
CN110490602A (zh) * 2018-05-09 2019-11-22 厦门本能管家科技有限公司 一种三层区块链架构构建方法及系统
US20190379546A1 (en) * 2018-06-12 2019-12-12 Chunghwa Telecom Co., Ltd. Method for reaching consensus on public distributed ledgers and system using the same
CN110705973A (zh) * 2018-07-10 2020-01-17 深圳市红砖坊技术有限公司 应用于区块链系统中矿工节点的共识方法和区块链系统
CN109039646A (zh) * 2018-07-12 2018-12-18 北京链享未来科技有限公司 一种基于节点能力的区块链区块打包和验证方法及系统
CN110457926A (zh) * 2019-08-13 2019-11-15 重庆邮电大学 一种工业物联网中基于数据加密存储的数据共享方法
CN110730225A (zh) * 2019-09-30 2020-01-24 北京中电拓方科技股份有限公司 基于区块链的物联网的数据处理方法、物联网及存储介质
CN111611311A (zh) * 2020-05-11 2020-09-01 芜湖明轩科技有限公司 去中心化分布式数据库的形成方法及系统、电子设备及计算机可读存储介质

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114219489A (zh) * 2021-12-24 2022-03-22 中远海运科技股份有限公司 一种实时上传交易信息的区块链存证方法

Also Published As

Publication number Publication date
CN111611311B (zh) 2023-09-08
CN111611311A (zh) 2020-09-01

Similar Documents

Publication Publication Date Title
US20240064007A1 (en) Methods and systems for blockchain-implemented event-lock encryption
CN110580653B (zh) 一种基于交易的区块链共识机制
EP3610436B1 (en) Rapid distributed consensus on blockchain
TWI659373B (zh) 區塊鏈系統及應用其的方法
Kim et al. SCC: Storage compression consensus for blockchain in lightweight IoT network
CN109313654B (zh) 使用布隆过滤器对被许可的区块链进行去同步恢复的方法和系统
CN114944932B (zh) 将区块添加到被许可的区块链的方法和系统
EP4060544A1 (en) Blockchain for general computation
CN111131209B (zh) 一种改进的高效共识方法、系统、计算机设备及存储介质
WO2021227867A1 (zh) 去中心化分布式数据库的形成方法及系统、电子设备及计算机可读存储介质
CN112468302A (zh) 基于可验证多方秘密分享的可编辑区块链
CN111080287B (zh) 一种业务数据的处理方法、相关设备和系统
CN113448694B (zh) 一种提高事务处理能力的区块链共识方法
Kim et al. A study on an energy-effective and secure consensus algorithm for private blockchain systems (PoM: Proof of Majority)
Aluko et al. Proof-of-reputation: an alternative consensus mechanism for blockchain systems
CN113939821A (zh) 用于在工作量证明区块链网络上进行非并行挖掘的系统和方法
CN113360951B (zh) 一种基于分区式区块链的电子证据保全方法
CN113360569B (zh) 基于储能参数选择与容量分解的电网区块链架构方法
CN113810185A (zh) 一种抗陷门泄露的链上数据修复系统及方法
KR20210127231A (ko) 동력화된 ID (Energized Identity) 기반 블록체인
Zhang et al. FortunChain: EC-VRF-based scalable blockchain system for realizing state sharding
CN117176321B (zh) 一种基于区块链技术的分布式信誉管理方法
WO2024087347A1 (zh) 一种区块链生成方法、系统及相应数据存储方法和系统
CN117787739B (zh) 可验证的跨链信誉计算方法和系统、评价和充电方法
CN117675669B (zh) 一种簇间区块传输方法、存储介质及计算设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21804574

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21804574

Country of ref document: EP

Kind code of ref document: A1