Blockchain Evidence Preservation Method, System, Terminal and Medium Based on Hybrid Consensus Algorithm
By adopting a hybrid consensus algorithm in the blockchain proof storage system, combining smart contracts and dynamic difficulty adjustment mechanisms, the problems of PoW's high energy consumption and PoS centralized risk are solved, and a more fair, decentralized and efficient blockchain proof storage system is achieved.
Patent Information
- Application Number
- CN202510443917.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-10
- Publication Date
- 2025-06-24
- Estimated Expiration
- 2045-04-10
AI Technical Summary
In the existing blockchain evidence storage system, the PoW mechanism is high in energy consumption and cannot respond to computing power fluctuations in real time, and the PoS mechanism may cause centralized risks and resource waste.
The blockchain evidence storage method based on a hybrid consensus algorithm is adopted to determine the PoW difficulty target of the block-producing node under the number of pledged equity through smart contracts, and adjust the difficulty of block-producing through a dynamic difficulty adjustment mechanism to respond to computing power fluctuations in real time.
A fairer and more decentralized blockchain evidence storage system has been realized, which avoids waste of resources, can respond to computing power fluctuations in real time, and attracts more users to participate.
Smart Images

Figure CN119963183B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain technology, and in particular to a blockchain evidence storage interaction method, device, terminal and medium based on a hybrid consensus algorithm. Background Art
[0002] As the core module of the blockchain evidence storage system, the consensus mechanism has emerged in its development history with two major mainstream technical routes represented by PoW (Proof of Work) and PoS (Proof of Stake), but a single mechanism has limitations that are difficult to overcome. The PoW mechanism is a mechanism that requires the calculation of a large number of complex mathematical problems to verify transactions. It is used to prevent malicious attacks and ensure the accuracy of blockchain data, but its high energy consumption has been criticized. The PoS mechanism determines the qualifications of the validator by the number of shares held and the holding time. Users who hold more shares and hold shares for a longer time have more motivation to ensure network security, but it may cause new centralization risks.
[0003] Traditional PoW uses a static difficulty adjustment mechanism that is unified across the entire network and cannot respond to fluctuations in computing power in real time, resulting in high energy consumption computing even under low load, causing a waste of resources.
[0004] Therefore, the prior art still has defects. Summary of the invention
[0005] The technical problem to be solved by the present invention is to provide a blockchain evidence storage method, system, terminal and medium based on a hybrid consensus algorithm in view of the above-mentioned defects of the prior art. The technical solution adopted by the present invention is as follows:
[0006] In a first aspect, the present invention provides a blockchain evidence storage method based on a hybrid consensus algorithm, wherein the method comprises:
[0007] The consensus cycle begins, and the initial structure of the local blockchain is generated based on the packaged transactions;
[0008] Call the smart contract on the blockchain and determine the PoW difficulty target of the block node based on the staked equity amount based on the smart contract;
[0009] Obtain candidate blocks that meet the PoW difficulty target;
[0010] The candidate block is subjected to the legitimacy verification, and after the candidate block passes the legitimacy verification, the block difficulty of the next block-producing node is adjusted based on the dynamic difficulty adjustment mechanism, and the consensus cycle is ended.
[0011] In one implementation, the consensus cycle begins by generating an initial structure of a local blockchain based on packaged transactions, including:
[0012] Obtain an evidence preservation request, encode the evidence preservation request into the parameter field of the transaction in the blockchain evidence preservation system to form a transaction on the blockchain, and put the formed transaction into the transaction pool;
[0013] Enter the consensus cycle, select transactions from the transaction pool for packaging, and generate the initial structure of the local blockchain based on the packaged transactions.
[0014] In one implementation, the hybrid consensus algorithm is to adjust the block generation difficulty coefficient of the whole network's basic PoW consensus algorithm based on the effective pledged equity quantity of the block-producing node to calculate the PoW difficulty target of the block-producing node under the pledged equity quantity. Determining the PoW difficulty target of the block-producing node under the pledged equity quantity based on the smart contract includes:
[0015] Record the address of the block-producing node and the effective pledged equity quantity S based on the smart contract;
[0016] Based on the hybrid consensus algorithm formula, calculate the PoW difficulty target D that the block-producing node needs to calculate under the effective pledged equity quantity S.
[0017] In one implementation, the hybrid consensus algorithm formula is:
[0018]
[0019] Among them, D is the PoW difficulty target, D0 is the block generation difficulty of the whole network's basic PoW consensus algorithm, S is the effective pledged equity quantity of the block-producing node, is the total equity quantity pledged by all block-producing nodes, is the pledge adjustment factor, 0 < < 1, is the adjustment factor for successfully mining a block, 0 < < 1, is the number of blocks recently mined by the block-producing node.
[0020] In one implementation, calculating the PoW difficulty target D that the block-producing node needs to calculate under the effective pledged equity quantity S based on the hybrid consensus algorithm formula includes:
[0021] Set a decay factor for the number of blocks mined by the block-producing node , and set a dynamic difficulty adjustment mechanism for the effective pledged equity quantity;
[0022] Based on the decay factor and the dynamic difficulty adjustment mechanism to adjust the hybrid consensus algorithm formula;
[0023] The adjusted hybrid consensus algorithm formula is:
[0024]
[0025] Among them, is the dynamic effective pledged equity quantity of the block-producing node, is the number of blocks mined by other block-producing nodes since the block-producing node mined the th block, is the decay factor of the number of blocks mined by each block-producing node, 0 < < 1, and N is the upper limit of the number of blocks mined by other nodes.
[0026] In one implementation, the obtaining of the candidate block when meeting the PoW difficulty target includes:
[0027] Performing PoW difficulty calculation to obtain a calculation result;
[0028] When the calculation result meets the PoW difficulty target, based on the PoW difficulty target, the calculation result, and the initial structure of the local blockchain, obtaining the candidate block.
[0029] In one implementation, the obtaining of the candidate block when the calculation result meets the PoW difficulty target, based on the PoW difficulty target, the calculation result, and the initial structure of the local blockchain, includes:
[0030] If the calculation result meets the PoW difficulty target, obtaining the pledged equity quantity corresponding to the PoW difficulty target;
[0031] Writing the pledged equity quantity, the PoW difficulty target, and the calculation result into the initial structure of the local blockchain as the block header to obtain the candidate block.
[0032] In one implementation, the legal verification of the candidate block includes:
[0033] Verifying whether the difficulty target in the candidate block is equal to the PoW difficulty target;
[0034] If the difficulty target in the candidate block is equal to the PoW difficulty target, verifying whether the calculation result in the candidate block is less than the PoW difficulty target;
[0035] If the calculation result in the candidate block is less than the PoW difficulty target, verifying whether the transactions in the candidate block conflict with the local ledger state;
[0036] If the transactions in the candidate block do not conflict with the local ledger state, the candidate block passes the legal verification.
[0037] In one implementation, after the candidate block passes the legality verification, based on the dynamic difficulty adjustment mechanism, the block generation difficulty of the next block generation node is adjusted, including:
[0038] After the candidate block passes the legality verification, update the weight function based on the dynamic difficulty adjustment mechanism to control the impact of the change in the pledged equity amount on the PoW difficulty target;
[0039] Based on the updated weight function, adjust the block generation difficulty of the next block generation node.
[0040] In one implementation, the formula of the dynamic difficulty adjustment mechanism is:
[0041] ,
[0042] wherein, ,
[0043] or, ,
[0044] wherein, is the current block height, is a constant, is an enumerated variable used to sequentially represent different blocks, is the initial pledged equity amount, is at the change amount of the pledged equity that occurs, is the weight function used to control the impact of the change amount of the pledged equity on the PoW difficulty target.
[0045] In one implementation, the method further includes:
[0046] During the consensus period, the smart contract records the pledged node address, the pledged equity quantity, the PoW difficulty target, and the node status information.
[0047] In one implementation, the method further includes:
[0048] After the consensus period ends, based on the execution node, execute all the transactions packaged in the candidate block, and after the execution is completed, perform persistent storage update on all the node status information on the blockchain.
[0049] In one implementation, the execution node is a consensus node.
[0050] In a second aspect, the present invention further provides a blockchain evidence storage system based on a hybrid consensus algorithm. The system is used to implement the steps of the blockchain evidence storage method based on the hybrid consensus algorithm described in any one of the above solutions. The blockchain evidence storage system based on the hybrid consensus algorithm includes:
[0051] The block-producing node pledges a certain amount of equity and generates the initial structure of the local blockchain based on the packaged transactions at the beginning of the consensus cycle.
[0052] The smart contract determines the PoW difficulty target of the block-producing node under the pledged equity amount based on the hybrid consensus algorithm.
[0053] The candidate block acquisition module is used to acquire candidate blocks when the PoW difficulty target is met.
[0054] The block production difficulty adjustment module is used to verify the legality of the candidate block, and after the candidate block passes the legality verification, adjust the block production difficulty of the next block-producing node based on the dynamic difficulty adjustment mechanism and end the consensus cycle.
[0055] In one implementation, the system further includes:
[0056] The execution node is used to execute all the packaged transactions in the candidate block, and after the execution is completed, perform persistent storage update on all the node status information on the blockchain.
[0057] In a third aspect, an embodiment of the present invention further provides a terminal. The terminal includes a memory, a processor, and a blockchain deposit program based on the hybrid consensus algorithm stored in the memory and executable on the processor. When the processor executes the blockchain deposit program based on the hybrid consensus algorithm, the steps of the blockchain deposit method based on the hybrid consensus algorithm in any one of the above solutions are implemented.
[0058] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium. A blockchain deposit program based on the hybrid consensus algorithm is stored on the computer-readable storage medium, and the blockchain deposit program based on the hybrid consensus algorithm implements the steps of the blockchain deposit method in any one of the above solutions on the computer-readable storage medium.
[0059] Advantageous effects: Compared with the prior art, the present invention provides a blockchain deposit and proof method based on a hybrid consensus algorithm. At the beginning of the consensus cycle of the present invention, an initial structure of the local blockchain is generated based on the packaged transactions. Then, a smart contract on the blockchain is called, and the PoW difficulty target for the block-producing node under the pledged equity amount is determined based on the smart contract. Next, candidate blocks that meet the PoW difficulty target are obtained. Then, the candidate blocks are subjected to legality verification, and after the candidate blocks pass the legality verification, based on the dynamic difficulty adjustment mechanism, the block-producing difficulty of the next block-producing node is adjusted, and the consensus cycle ends. Finally, all the packaged transactions in the candidate blocks are executed, and after the execution is completed, the states of all nodes are updated. The present invention applies the dynamic difficulty adjustment mechanism to the blockchain deposit and proof system. Compared with the traditional consensus mechanism, the present invention can respond to the computing power fluctuation in real time, is more fair and more decentralized while avoiding resource waste, and can attract more users to participate in the entire system. Description of the Drawings
[0060] Figure 1 It is a flowchart of a preferred embodiment of the blockchain deposit and proof method based on a hybrid consensus algorithm provided by an embodiment of the present invention.
[0061] Figure 2 It is an overall interaction schematic diagram of the blockchain deposit and proof method based on a hybrid consensus algorithm provided by the present invention.
[0062] Figure 3 It is a schematic flowchart of the consensus cycle in the blockchain deposit and proof method based on a hybrid consensus algorithm provided by the present invention.
[0063] Figure 4 It is a schematic architecture diagram of the dynamic difficulty adjustment mechanism in the blockchain deposit and proof system based on a hybrid consensus algorithm provided by an embodiment of the present invention.
[0064] Figure 5 It is a principle block diagram of the terminal provided by an embodiment of the present invention. Detailed Embodiments
[0065] To make the objectives, technical solutions and effects of the present invention clearer and more definite, the following further describes the present invention in detail with reference to the accompanying drawings and by way of examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0066] The flowchart shown in the drawings is only an example illustration, and does not necessarily include all the contents and operations or steps, nor is it necessary to be executed in the described order. For example, some operations or steps can also be decomposed, combined or partially merged, so the actual execution order may be changed according to the actual situation.
[0067] It should be understood that the terms used in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include the plural forms.
[0068] It should be understood that, for the convenience of clearly describing the technical solutions of the embodiments of the present invention, in the embodiments of the present invention, terms such as "first" and "second" are used to distinguish identical or similar items with basically the same functions and roles. For example, the first control information and the second control information are only used to distinguish different control information, and do not limit their sequence.
[0069] Those skilled in the art can understand that the terms such as "first" and "second" do not limit the quantity and execution order, and the terms such as "first" and "second" do not necessarily mean different.
[0070] It should also be understood that the term "and / or" used in the specification of the present invention and the appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0071] The PoW consensus realizes the decentralized accounting right allocation through hash calculation competition, but its high energy consumption problem has been widely criticized.
[0072] The PoS consensus replaces the computing power competition with the amount of pledged equity. Although it significantly reduces energy consumption, it triggers new centralization risks. Data from Ethereum 2.0 shows that the top 1% of addresses hold more than 35% of the pledged quota, forming the Matthew effect of "the rich getting richer", and there is a long-range attack vulnerability. Attackers can use historical shareholding records to forge a forked chain.
[0073] To reconcile the contradictions between the two mechanisms, early hybrid consensus schemes tried to simply superimpose PoW and PoS. PoW generates blocks and PoS validates blocks. However, their parameters are set independently and there is no dynamic association. All nodes, regardless of their computing power and the amount of pledged equity, share the same PoW difficulty, resulting in resource waste and efficiency loss. Moreover, the PoW difficulty is not incorporated into the adjustment framework and cannot respond to network fluctuations in real time.
[0074] Based on the defects of the prior art, the present embodiment provides a blockchain deposit and proof method based on a hybrid consensus algorithm, which can be applied to a blockchain deposit and proof system. As Figure 1 shown, the blockchain deposit and proof method based on the hybrid consensus algorithm of the present embodiment includes the following steps:
[0075] Step S100: At the beginning of the consensus period, generate an initial structure of the local blockchain based on the packaged transactions.
[0076] Combined Figure 2 As shown, in this embodiment, the user first initiates a deposit request to the blockchain deposit system. This deposit request can be in the form of network communication such as HTTP. The deposit request can include information such as the deposit file, timestamp, file hash, etc. When the blockchain deposit system obtains the deposit request, it can encode the deposit request into the parameter field of the blockchain deposit system transaction to form a transaction on the blockchain, and put the formed transaction into the transaction pool. The specific encoding method can use base16 encoding. Then, the blockchain deposit system enters the consensus cycle. The time of this consensus cycle can be determined by the initial parameters of the blockchain. For example, it can be determined that 10 seconds is a consensus cycle. Combined Figure 3 As shown, after the consensus cycle starts, the consensus node can select a batch of transactions from the transaction pool for packaging, and generate the initial structure of the local block based on the packaged transactions. The initial structure of this local block can include information such as version number, timestamp, hash value of the previous block, and the root of the Merkle tree composed of all transaction hashes.
[0077] Step S200: Invoke the smart contract on the blockchain, and based on the smart contract, determine the PoW difficulty target under the pledged equity quantity of the block-producing node.
[0078] Next, the consensus node invokes the smart contract on the blockchain deposit system, locks a certain amount of pledged equity, and records the address of the block-producing node and the effective pledged equity quantity S based on the smart contract. Different from the prior art solution of simply superimposing PoW and PoS to form a hybrid consensus, in this embodiment, the smart contract calculates the PoW difficulty target D that the block-producing node needs to calculate under the effective pledged equity quantity S through the hybrid consensus algorithm formula, and the smart contract also records information such as the PoW difficulty target D. The entire recording process of the smart contract lasts at least one complete consensus cycle, and the pledged equity quantity S will not be transferred or modified during this period. By directly coupling the effective pledged equity quantity S of the block-producing node address to the calculation of the PoW difficulty target D, this embodiment constructs a two-way constrained hybrid consensus architecture, which not only inhibits the wealth centralization trend of pure PoS but also avoids the problem of wasted computing power of pure PoW, significantly improving the openness and fairness of the network.
[0079] Specifically, this embodiment adjusts the coefficient of the block production difficulty of the whole network's basic PoW consensus algorithm based on the effective pledged equity quantity of the block-producing node. The adjustment formula is as follows:
[0080]
[0081] This formula can be expressed as an inverse relationship between the number of stakes pledged by a block-producing node and the difficulty of producing blocks. The more stakes a block-producing node has, the lower the difficulty of producing blocks using its PoW consensus algorithm. Among them, D is the PoW difficulty target, D0 is the difficulty of producing blocks using the basic PoW consensus algorithm for the entire network, is the total amount of equity pledged by all block-producing nodes, S is the number of valid pledged equity corresponding to the block-producing node, is a tuning parameter (0< < 1), controlling the impact of the number of pledged shares on the difficulty of producing blocks. / Indicates the proportion of the total amount of pledged equity held by the block-producing nodes.
[0082] This embodiment also uses another positive adjustment parameter to indicate the increase in the difficulty of producing blocks. This positive adjustment parameter is based on the number of blocks recently mined by the producing node. The adjusted formula is as follows:
[0083]
[0084] in, is another tuning parameter (0 < <1), is the adjustment factor for successfully mining a block. When a block-producing node successfully mines a block, the difficulty of the next block-producing node should be increased to prevent the formation of the Matthew effect of "the rich get richer". It is the number of blocks recently mined by the block-producing node.
[0085] Next, this embodiment further considers the attenuation of the influence of the blocks that have been mined on the difficulty of generating blocks, that is, the closer the time to the last block generation, the greater the influence; conversely, the smaller the influence. To this end, the embodiment sets an attenuation factor for the number of mined blocks. , and at the same time, consider a maximum value N, N is the upper limit of the number of blocks mined by other nodes. If it exceeds the maximum value N, even if the number of mined blocks increases, the impact on the block difficulty adjustment of a block-producing node can be ignored. The adjusted formula is:
[0086]
[0087] in, It is mined from the block node The number of blocks mined by other block-producing nodes since blocks. The attenuation factor for the influence of each mined block, the attenuation factor (0 < <1)Used to control the decay rate.
[0088] In this embodiment, the above two adjustment methods can be combined, and the product of the above two adjustment methods can be used as the adjustment formula, as follows:
[0089]
[0090] The value of each variable used in the above adjustment formula is data available on the blockchain, such as the difficulty target of the block. The difficulty of generating blocks based on the PoW consensus algorithm of the entire network , the number of valid pledged shares of the block-producing node And the total amount of equity pledged by all block-producing nodes , the number of blocks mined by other block-producing nodes since the block-producing node mined the i-th block By adopting variable values that can be verified by the entire network (including algorithm-configurable adjustment factors) to implement the above adjustment formula, it is helpful to prevent the possibility of tampering. Of course, in other implementations, this embodiment can also obtain the adjustment formula by weighting the above two adjustment methods, and the present invention is not limited to this.
[0091] Since the number of pledged shares will affect the difficulty of block generation, when the number of pledged shares changes dynamically, for example, when the number of pledged shares increases or decreases significantly, resulting in an instantaneous change in the difficulty of block generation, it may cause sudden fluctuations in computing power, causing the entire blockchain evidence storage system to undergo drastic and uncontrollable changes due to changes in the number of pledged shares in the block generation node. This embodiment adopts a dynamic difficulty adjustment mechanism so that the dynamic changes in the number of pledged shares have a gradual impact on the system, avoiding sudden fluctuations in computing power caused by instantaneous changes in the difficulty of block generation. Taking into account the dynamic increase and decrease in the number of pledged shares of each node PoS difficulty, this embodiment adopts a dynamic effective number of pledged shares. Instead of the effective pledged equity quantity S, the above block node difficulty adjustment formula will become:
[0092]
[0093] is the number of dynamic and effective pledged shares of the block-producing node. Based on the original adjustment formula, this embodiment further realizes that the dynamic change of the number of pledged shares gradually affects the computing power and the difficulty of producing blocks, thereby obtaining the hybrid consensus algorithm formula of this embodiment. This improvement enhances the flexibility and decentralization of the algorithm, while avoiding sudden fluctuations in computing power caused by changes in the number of pledged shares.
[0094] Step S300: Obtain candidate blocks that meet the PoW difficulty target.
[0095] Further, the consensus node obtains from the smart contract the PoW difficulty target D that it needs to calculate under the current pledged equity quantity S in this consensus cycle. Then, the consensus node performs PoW difficulty calculation based on its own computing power until the calculation result R satisfies the PoW difficulty target D. The essence of PoW difficulty calculation is to continuously traverse a random number until the calculation result R satisfies the PoW difficulty target D, obtain the pledged equity quantity corresponding to the PoW difficulty target, and then write the pledged equity quantity S, the PoW difficulty target D, and the calculation result R into the initial structure of the local blockchain as the block header to obtain the candidate block.
[0096] Step S400: Perform legality verification on the candidate block, and after the candidate block passes the legality verification, based on the dynamic difficulty adjustment mechanism, adjust the block production difficulty of the next block-producing node, and end this consensus cycle.
[0097] The consensus node broadcasts the candidate block to the entire network, and other nodes will perform legality verification on this candidate block. Specifically, during the verification process, verify whether the difficulty target in the candidate block is equal to the PoW difficulty target; if the difficulty target in the candidate block is equal to the PoW difficulty target, then verify whether the calculation result in the candidate block is less than the PoW difficulty target; if the calculation result in the candidate block is less than the PoW difficulty target, then verify whether the transactions in the candidate block conflict with the local ledger state. If the transactions in the candidate block do not conflict with the local ledger state, then the candidate block passes the legality verification and saves this candidate block, and this candidate block will be accepted by all users as a valid block. At this time, this candidate block will be added to the blockchain. If the candidate block is illegal, then discard this candidate block.
[0098] If the candidate block passes the verification, at this time, the weight function can be updated based on the dynamic difficulty adjustment mechanism to gradually control the influence of the change in pledged equity quantity on the PoW difficulty target; then, based on the updated weight function, adjust the block production difficulty target of the next block-producing node and end the consensus cycle. In the next consensus cycle, the weight functions obtained by each node through pledged equity will be recalculated after readjustment. Specifically, the dynamic difficulty adjustment mechanism of this embodiment The formula is:
[0099] ,
[0100] where, is the current block height, is a constant, is an enumerated variable used to represent different blocks in sequence, is the initial pledged equity quantity, is at The amount of pledged equity changes that occur when is a weight function used to control the impact of the amount of pledged equity changes on the PoW difficulty target. The weight function of this embodiment can adopt the following piecewise function:
[0101] ,
[0102] or, .
[0103] It can be seen that this embodiment applies the method of the dynamic difficulty adjustment mechanism to the blockchain deposit and proof system, making the impact of the dynamic change of the pledged equity quantity on the blockchain deposit and proof system gradually occur, and avoiding the instantaneous change of the block production difficulty. Compared with the traditional consensus mechanism, this embodiment takes into account the dynamic change of the pledged equity quantity and its gradual impact on the computing power and block production difficulty, is more fair and more decentralized, attracts more users to participate in the whole system, avoids the problem of equity centralization caused by PoS, and at the same time avoids the resource waste caused by PoW. Compared with the method of fixing or periodically updating the difficulty in the traditional hybrid consensus, this embodiment introduces a multi-dimensional based difficulty adjustment algorithm, dynamically adjusts the PoW / PoS weight according to the dynamic pledged equity quantity distribution, transaction load and security threat, so as to balance the block production difficulty targets of each block production node in the blockchain deposit and proof system, and is more stable and secure, taking into account fairness.
[0104] In this embodiment, during the consensus cycle, the smart contract will record the pledged node address, the amount of pledged equity, the PoW difficulty target, and the node status information. After the consensus cycle ends, the execution node in the blockchain deposit and proof system executes all the packaged transactions in the candidate block, that is, executes the deposit and proof request. After the execution is completed, the persistent storage of all the node status information on the blockchain is updated, and this round of interaction process ends. In practical applications, the execution node can be a consensus node. After executing all the packaged transactions in the candidate block, the execution engine of the execution node will perform persistent storage on the status of all nodes on the blockchain. For example, the transactions in a candidate block can be: Transaction 1 and Transaction 2, both of which are equity transfer operations. At this time, the execution node calls the smart contract related to equity transfer on the blockchain. After the execution engine executes these two transactions, it will update the equity balances of the nodes involved in these two transactions and re-persistently store them on the blockchain.
[0105] In summary, the present invention constructs a hybrid consensus architecture with two-way constraints by directly coupling the pledged equity quantity of nodes to the calculation of the PoW difficulty target, which not only inhibits the wealth centralization trend of pure PoS but also avoids the problem of computing power waste in pure PoW, significantly enhancing the openness and fairness of the network. Moreover, the present invention applies the method of the dynamic difficulty adjustment mechanism to the blockchain evidence storage system, which is fairer, more decentralized, and avoids resource waste compared with the traditional consensus mechanism, attracting more users to participate in the entire system.
[0106] Based on the above embodiments, the present invention further provides a blockchain evidence storage system based on a hybrid consensus algorithm, which is used to implement the steps in the above method embodiments, such as Figure 4 As shown, the system includes: a block-producing node 10, a smart contract 20, a candidate block acquisition module 30, and a block-producing difficulty adjustment module 40. Specifically, the block-producing node 10 pledges a certain quantity of equity and generates an initial local blockchain structure based on the packaged transactions at the beginning of the consensus cycle; the smart contract 20 determines the PoW difficulty target of the block-producing node under the pledged equity quantity based on the hybrid consensus algorithm; the candidate block acquisition module 30 is used to acquire candidate blocks that meet the PoW difficulty target; the block-producing difficulty adjustment module 40 is used to perform a legality verification on the candidate blocks, and after the candidate blocks pass the legality verification, based on the dynamic difficulty adjustment mechanism, adjust the block-producing difficulty of the next block-producing node and end the consensus cycle.
[0107] In one implementation, the system further includes an execution node, which is used to execute all the packaged transactions in the candidate blocks and, after the execution is completed, perform a persistent storage update on all the node status information on the blockchain.
[0108] In the blockchain evidence storage system based on the hybrid consensus algorithm of this embodiment, the working principles of each module are the same as those of each step in the above method embodiment, and will not be elaborated here.
[0109] Each module in the above blockchain evidence storage system based on the hybrid consensus algorithm can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in the processor in the terminal in hardware form or be independent of the processor, or can be stored in the memory in the terminal in software form, so as to facilitate the processor to call and execute the operations corresponding to each of the above modules.
[0110] Based on the above embodiments, the present invention further provides a terminal, and the principle block diagram of the terminal can be as Figure 5 As shown. The terminal can include one or more processors 100 ( Figure 5Only one is shown in the figure), a memory 101, and a computer program 102 stored in the memory 101 and executable on one or more processors 100. For example, a blockchain deposit and proof program based on a hybrid consensus algorithm. When the one or more processors 100 execute the computer program 102, each step in the embodiment of the blockchain deposit and proof method based on the hybrid consensus algorithm can be implemented. Alternatively, when the one or more processors 100 execute the computer program 102, the functions of each module / unit in the embodiment of the blockchain deposit and proof system based on the hybrid consensus algorithm can be implemented, which is not limited herein.
[0111] In one embodiment, the so-called processor 100 may be a central processing unit (CPU), or may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0112] In one embodiment, the memory 101 may be an internal storage unit of the electronic device, such as the hard disk or memory of the electronic device. The memory 101 may also be an external storage device of the electronic device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device. Further, the memory 101 may also include both the internal storage unit and the external storage device of the electronic device. The memory 101 is used to store the computer program and other programs and data required by the terminal. The memory 101 may also be used to temporarily store the data that has been output or will be output.
[0113] Those skilled in the art can understand that Figure 5 The principle block diagram shown in the figure is only a block diagram of some structures related to the solution of the present invention, and does not constitute a limitation on the terminal to which the solution of the present invention is applied. The specific terminal may include more or fewer components than those shown in the figure, or combine some components, or have a different component layout.
[0114] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, storage, operational database, or other medium used in the embodiments provided by the present invention can include non-volatile and / or volatile memories. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and Rambus dynamic RAM (RDRAM), etc.
[0115] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments or equivalently replace some of the technical features. These modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A blockchain evidence storage method based on a hybrid consensus algorithm, characterized in that: The method comprises: The consensus cycle begins, and the initial structure of the local blockchain is generated based on the packaged transactions; Call the smart contract on the blockchain and determine the PoW difficulty target of the block node based on the staked equity amount based on the smart contract; Obtain candidate blocks that meet the PoW difficulty target; Verify the legitimacy of the candidate block, and after the candidate block passes the legitimacy verification, adjust the block difficulty of the next block-producing node based on the dynamic difficulty adjustment mechanism, and end the consensus cycle; The hybrid consensus algorithm is to adjust the coefficient of the block difficulty of the basic PoW consensus algorithm of the whole network based on the number of effective pledged shares of the block node to calculate the PoW difficulty target of the block node under the number of pledged shares. The determination of the PoW difficulty target of the block node under the number of pledged shares based on the smart contract includes: Based on the smart contract, the address of the block producing node and the number of valid pledged shares S are recorded; Based on the hybrid consensus algorithm formula, the PoW difficulty target D that the block producing node needs to calculate under the effective pledged equity quantity S is calculated; The formula of the hybrid consensus algorithm is: Among them, D is the PoW difficulty target, D0 is the block difficulty of the basic PoW consensus algorithm of the whole network, S is the number of valid pledged shares of the block node, S total is the total amount of equity pledged by all block-producing nodes, α is the pledge adjustment factor, 0<α<1, β is the adjustment factor for successfully mined blocks, 0<β<1, and k is the number of blocks mined by the block-producing node recently; The formula for the dynamic difficulty adjustment mechanism is: in, or, Among them, S eff is the number of dynamic valid pledged shares of the block-producing node, h is the current block height, T is a constant, t is an enumeration variable used to represent different blocks in sequence, S base is the initial pledged equity amount, ΔS t1 is the change in pledged equity at t1, and f(t,h,T) is the weight function used to control the impact of the change in pledged equity on the PoW difficulty target.
2. The blockchain evidence storage method based on the hybrid consensus algorithm according to claim 1 is characterized in that: The consensus cycle begins, and the initial structure of the local blockchain is generated based on the packaged transactions, including: Obtain a certificate storage request, encode the certificate storage request into a parameter field of a blockchain certificate storage system transaction, form a transaction on the blockchain, and place the formed transaction into a transaction pool; Entering the consensus cycle, selecting transactions from the transaction pool for packaging, and generating the initial structure of the local blockchain based on the packaged transactions.
3. The blockchain evidence storage method based on the hybrid consensus algorithm according to claim 1 is characterized in that: The hybrid consensus algorithm formula is used to calculate the PoW difficulty target D that the block producing node needs to calculate under the effective pledged equity quantity S, including: A decay factor γ is set for the number of blocks mined by the block-producing node, and a dynamic difficulty adjustment mechanism is set for the number of valid pledged shares; Adjusting the hybrid consensus algorithm formula based on the attenuation factor γ and the dynamic difficulty adjustment mechanism; The adjusted hybrid consensus algorithm formula is: Among them, n i It is the number of blocks mined by other block-producing nodes since the block-producing node mined the i-th block. γ is the attenuation factor of the number of blocks mined by each block-producing node, 0<γ<1, and N is the upper limit of the number of blocks mined by other nodes.
4. The blockchain evidence storage method based on the hybrid consensus algorithm according to claim 1 is characterized in that: The obtaining of a candidate block that meets the PoW difficulty target includes: Perform PoW difficulty calculation and obtain the calculation result; When the calculation result meets the PoW difficulty target, a candidate block is obtained based on the PoW difficulty target, the calculation result and the initial structure of the local blockchain.
5. The blockchain evidence storage method based on the hybrid consensus algorithm according to claim 4 is characterized in that: When the calculation result meets the PoW difficulty target, a candidate block is obtained based on the PoW difficulty target, the calculation result and the initial structure of the local blockchain, including: If the calculation result meets the PoW difficulty target, the number of pledged shares corresponding to the PoW difficulty target is obtained; The pledged equity quantity, the PoW difficulty target, and the calculation result are written into the local blockchain initial structure as a block header to obtain the candidate block.
6. The blockchain evidence storage method based on the hybrid consensus algorithm according to claim 5 is characterized in that: The verifying the legitimacy of the candidate block includes: Verify whether the difficulty target in the candidate block is equal to the PoW difficulty target; If the difficulty target in the candidate block is equal to the PoW difficulty target, verify whether the calculation result in the candidate block is less than the PoW difficulty target; If the calculation result in the candidate block is less than the PoW difficulty target, verify whether the transaction in the candidate block conflicts with the local ledger state; If the transactions in the candidate block do not conflict with the local ledger state, the candidate block passes the legitimacy verification.
7. The blockchain evidence storage method based on the hybrid consensus algorithm according to claim 6 is characterized in that: After the candidate block passes the legitimacy verification, the difficulty of the next block-producing node is adjusted based on the dynamic difficulty adjustment mechanism, including: After the candidate block passes the legitimacy verification, the weight function is updated based on the dynamic difficulty adjustment mechanism to control the impact of changes in the amount of pledged equity on the PoW difficulty target; Based on the updated weight function, adjust the difficulty of the next block-producing node.
8. The blockchain evidence storage method based on the hybrid consensus algorithm according to claim 1 is characterized in that: The method further comprises: During the consensus cycle, the smart contract records the staked node address, the amount of staked equity, the PoW difficulty target, and the node status information.
9. The blockchain evidence storage method based on the hybrid consensus algorithm according to claim 8 is characterized in that , the method further comprises: After the consensus cycle is over, all packaged transactions in the candidate block are executed based on the execution node, and after the execution is completed, all node status information on the blockchain is persistently stored and updated.
10. The blockchain evidence storage method based on the hybrid consensus algorithm according to claim 9 is characterized in that ,The execution node is a consensus node.
11. A blockchain evidence storage system based on a hybrid consensus algorithm, characterized in that: The system is used to implement the steps of the blockchain evidence storage method based on the hybrid consensus algorithm according to any one of claims 1 to 10, and the blockchain evidence storage system based on the hybrid consensus algorithm includes: Block producing nodes pledge a certain amount of equity and generate the initial structure of the local blockchain based on the packaged transactions at the beginning of the consensus cycle; A smart contract determines the PoW difficulty target of the block producing node under the pledged equity amount based on the hybrid consensus algorithm; A candidate block acquisition module, used to acquire candidate blocks that meet the PoW difficulty target; The block difficulty adjustment module is used to verify the legitimacy of the candidate block, and after the candidate block passes the legitimacy verification, adjust the block difficulty of the next block node based on the dynamic difficulty adjustment mechanism, and end the consensus cycle.
12. The blockchain evidence storage system based on the hybrid consensus algorithm according to claim 11 is characterized in that: The system further comprises: The execution node is used to execute all the packaged transactions in the candidate block, and after the execution is completed, the persistent storage and update of all node status information on the blockchain.
13. A terminal, characterized in that: The terminal includes a memory, a processor, and a blockchain evidence storage program based on a hybrid consensus algorithm stored in the memory and executable on the processor. When the processor executes the blockchain evidence storage program based on the hybrid consensus algorithm, the steps of the blockchain evidence storage method based on the hybrid consensus algorithm as described in any one of claims 1 to 10 are implemented.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a blockchain evidence storage program based on a hybrid consensus algorithm, and the blockchain evidence storage program based on a hybrid consensus algorithm implements the steps of the blockchain evidence storage method based on a hybrid consensus algorithm as described in any one of claims 1 to 10 on the computer-readable storage medium.
Citation Information
Patent Citations
DPoS consensus method and device
CN110298757A
Blockchain consensus method and system of multi-layer fragmentation architecture
CN110868434A