Block chain evidence storage method and system based on hybrid consensus algorithm, terminal and medium

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 resource utilization blockchain proof storage system is achieved.

CN119963183AActive Publication Date: 2025-05-09INT DIGITAL ECONOMY ACAD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510443917.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-10
Publication Date
2025-05-09
Estimated Expiration
2045-04-10

AI Technical Summary

Technical Problem

In the existing blockchain evidence storage system, the PoW mechanism is high in energy consumption and wastes resources, while the PoS mechanism may cause centralized risks. The traditional consensus mechanism cannot respond to computing power fluctuations in real time.

Method used

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.

Benefits of technology

A fairer and more decentralized blockchain evidence storage system has been realized, which avoids waste of resources, enhances the openness and fairness of the network, and attracts more users to participate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119963183A_ABST
    Figure CN119963183A_ABST
Patent Text Reader

Abstract

The invention discloses a block chain evidence storage method and system based on a hybrid consensus algorithm, a terminal and a medium, and the method comprises the steps: starting a consensus period, and generating a local block chain initial structure based on a packaged transaction; calling a smart contract on the block chain, and determining a PoW difficulty target of the block node under the number of pledge equity based on the smart contract; obtaining a candidate block meeting the PoW difficulty target; and carrying out legality verification on the candidate block, adjusting the block outlet difficulty of the next block outlet node based on a dynamic difficulty adjustment mechanism after the candidate block passes the legality verification, and ending the consensus period. According to the method, a dynamic difficulty adjustment mechanism is applied to the block chain evidence storage system, compared with a traditional consensus mechanism, the method is more fair and decentralized, meanwhile, resource waste is avoided, and more users can be attracted to participate in the whole system.
Need to check novelty before this filing date? Find Prior Art

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: In a first aspect, the present invention provides a blockchain evidence storage method based on a hybrid consensus algorithm, wherein 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; 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.

[0006] In one implementation, the consensus cycle begins by generating an initial structure of a local blockchain based on 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.

[0007] In one implementation, the hybrid consensus algorithm is to adjust the coefficient of the block difficulty of the basic PoW consensus algorithm of the entire network based on the number of valid pledged shares of the block node to calculate the PoW difficulty target of the block node under the number of pledged shares, and 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.

[0008] In one implementation, the hybrid consensus algorithm formula is:

[0009] Among them, D is the PoW difficulty target, D 0 is the difficulty of the PoW consensus algorithm for the entire network, S is the number of valid pledged shares of the block node, S total The total amount of equity pledged by all block-producing nodes, is the pledge adjustment factor, 0< <1, is the adjustment factor for successfully mining a block, 0< <1, The number of blocks mined recently by the block-producing node.

[0010] In one implementation, the calculation of 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: Set a decay factor for the number of blocks mined by the block-producing node and set up a dynamic adjustment mechanism for the number of valid pledged shares ; Based on the attenuation factor and the dynamic adjustment mechanism Adjusting the hybrid consensus algorithm formula; The adjusted hybrid consensus algorithm formula is:

[0011] in, is the number of dynamic and effective pledged shares of the block-producing node, It is mined from the block node The number of blocks mined by other block-producing nodes since blocks, The decay factor of the number of blocks mined by each block-producing node, 0< <1, N is the upper limit of the number of blocks mined by other nodes.

[0012] In one implementation, obtaining 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.

[0013] In one implementation, when the calculation result meets the PoW difficulty target, obtaining a candidate block based on the PoW difficulty target, the calculation result, and the initial structure of the local blockchain includes: 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.

[0014] In one implementation, 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.

[0015] In one implementation, after the candidate block passes the legitimacy verification, the difficulty of the next block generation 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.

[0016] In one implementation, the formula for the dynamic difficulty adjustment mechanism is: , in, , or, , in, is the current block height, is a constant, is an enumeration variable, used to represent different blocks in sequence. is the initial pledged equity amount, For The change in pledged equity at the time of It is a weight function used to control the impact of changes in pledged equity on the PoW difficulty target.

[0017] In one implementation, the method further includes: 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.

[0018] In one implementation, the method further includes: 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.

[0019] In one implementation, the execution node is a consensus node.

[0020] In a second aspect, the present invention further provides a blockchain evidence storage system based on a hybrid consensus algorithm, the system being used to implement the steps of the blockchain evidence storage method based on a hybrid consensus algorithm described in any one of the above schemes, the blockchain evidence storage system based on a hybrid consensus algorithm comprising: 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.

[0021] In one implementation, the system further includes: 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.

[0022] In a third aspect, an embodiment of the present invention further provides a terminal, wherein 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, and when the processor executes the blockchain evidence storage program based on a hybrid consensus algorithm, the steps of the blockchain evidence storage method based on a hybrid consensus algorithm of any one of the above-mentioned schemes are implemented.

[0023] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein a blockchain evidence storage program based on a hybrid consensus algorithm is stored on the computer-readable storage medium, 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 described in any one of the above-mentioned schemes on the computer-readable storage medium.

[0024] Beneficial effects: Compared with the prior art, the present invention provides a blockchain evidence storage method based on a hybrid consensus algorithm. At the beginning of the consensus cycle of the present invention, the initial structure of the local blockchain is generated based on the packaged transactions. Then, the smart contract on the blockchain is called, and the PoW difficulty target of the block node under the number of pledged shares is determined based on the smart contract. Then, the candidate block that meets the PoW difficulty target is obtained. Then, the legitimacy of the candidate block is verified, and after the candidate block passes the legitimacy verification, the block difficulty of the next block node is adjusted based on the dynamic difficulty adjustment mechanism, and the consensus cycle is ended. Finally, all packaged transactions in the candidate block are executed, and after the execution is completed, the status of all nodes is updated. The present invention applies the dynamic difficulty adjustment mechanism to the blockchain evidence storage system. Compared with the traditional consensus mechanism, the present invention can respond to computing power fluctuations in real time, avoid resource waste while being fairer and more decentralized, and attract more users to participate in the entire system. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 A flowchart of a preferred embodiment of a blockchain evidence storage method based on a hybrid consensus algorithm provided in an embodiment of the present invention.

[0026] Figure 2 This is a schematic diagram of the overall interaction of the blockchain evidence storage method based on the hybrid consensus algorithm provided by the present invention.

[0027] Figure 3 A schematic diagram of the consensus cycle in the blockchain evidence storage method based on the hybrid consensus algorithm provided by the present invention.

[0028] Figure 4 A schematic diagram of the architecture of a dynamic difficulty adjustment mechanism in a blockchain evidence storage system based on a hybrid consensus algorithm provided in an embodiment of the present invention.

[0029] Figure 5 A functional block diagram of a terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0030] In order to make the purpose, technical solution and effect of the present invention clearer and more specific, the present invention is further described in detail with reference to the accompanying drawings and 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.

[0031] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations or steps, nor must they be executed in the order described. For example, some operations or steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.

[0032] It should be understood that the terms used in this 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 plural forms. It should be understood that, in order to clearly describe the technical solutions of the embodiments of the present invention, in the embodiments of the present invention, words such as "first" and "second" are used to distinguish between identical or similar items with substantially identical functions and effects. For example, the first control information and the second control information are only used to distinguish different control information, and their order is not limited. Those skilled in the art can understand that the words "first", "second", etc. do not limit the quantity and execution order, and the words "first", "second", etc. do not necessarily limit the differences. It should be further understood that the term “and / or” used in the present specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0033] PoW consensus achieves decentralized accounting rights distribution through hash computing competition, but its high energy consumption has been criticized. Studies have shown that the annual power consumption of the Bitcoin network exceeds 130 TWh, and computing power is increasingly concentrated in a few large computing nodes, resulting in a high threshold for ordinary nodes to participate.

[0034] The PoS consensus replaces computing power competition with the amount of pledged equity. Although it significantly reduces energy consumption, it triggers new centralization risks. Ethereum 2.0 data shows that the top 1% of addresses hold more than 35% of the pledged amount, forming a Matthew effect of "the rich get richer". There is also a long-range attack vulnerability, and attackers can use historical shareholding records to forge a forked chain.

[0035] In order to reconcile the contradiction between the two mechanisms, early hybrid consensus schemes attempted to simply superimpose PoW and PoS, with PoW generating blocks and PoS verifying blocks. However, the parameters of the two were set independently and had no dynamic connection. All nodes, regardless of their computing power and the amount of staked shares, shared the same PoW difficulty, resulting in waste of resources and loss of efficiency. In addition, the PoW difficulty was not included in the adjustment framework, and it was impossible to respond to network fluctuations in real time.

[0036] Based on the defects of the prior art, this embodiment provides a blockchain evidence storage method based on a hybrid consensus algorithm, which can be applied to a blockchain evidence storage system. Figure 1 As shown in , the blockchain evidence storage method based on the hybrid consensus algorithm of this embodiment includes the following steps: Step S100: The consensus cycle begins, and the initial structure of the local blockchain is generated based on the packaged transactions.

[0037] Combination Figure 2 As shown, in this embodiment, the user first initiates a proof request to the blockchain proof system. The proof request may be through a network communication method such as HTTP. The proof request may include proof files, timestamps, file hashes and other information. When the blockchain proof system obtains the proof request, it may encode the proof request into the parameter field of the blockchain proof system transaction to form a transaction on the blockchain, and place the formed transaction into the transaction pool. The specific encoding method may use base16 encoding. Next, the blockchain proof system enters the consensus cycle. The duration of the consensus cycle may be determined by the initial parameters of the blockchain. For example, 10 seconds may be determined as a consensus cycle. Combined with Figure 3 As shown, after the consensus cycle begins, 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 the local block may include information such as the version number, timestamp, hash value of the previous block, and the root of the Merkle tree composed of all transaction hashes.

[0038] Step S200: calling the smart contract on the blockchain, and determining the PoW difficulty target of the block producing node under the pledged equity quantity based on the smart contract.

[0039] Next, the consensus node calls the smart contract on the blockchain evidence storage system to lock a certain number of pledged shares, and records the address of the block node and the number of valid pledged shares 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 node needs to calculate under the valid pledged equity number S through the hybrid consensus algorithm formula, and the smart contract also records the PoW difficulty target D and other information. The entire recording process of the smart contract maintains at least one complete consensus cycle, and the number of pledged shares S will not be transferred or modified during this period. This embodiment constructs a two-way constrained hybrid consensus architecture by directly coupling the valid pledged equity number S of the address of the block node to the calculation of the PoW difficulty target D, which not only suppresses the wealth concentration trend of pure PoS, but also avoids the problem of waste of computing power of pure PoW, significantly improving the openness and fairness of the network.

[0040] Specifically, this embodiment adjusts the coefficient of the difficulty of the whole network's basic PoW consensus algorithm based on the number of valid pledged shares of the block-producing node. The adjustment formula is as follows:

[0041] 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 by its PoW consensus algorithm. 0 The difficulty of generating blocks based on the PoW consensus algorithm of 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.

[0042] 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:

[0043] 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.

[0044] 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:

[0045] 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.

[0046] 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:

[0047] 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.

[0048] 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 adjustment mechanism so that the impact of dynamic changes in the number of pledged shares on the system occurs gradually, 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:

[0049] 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.

[0050] Step S300: Obtain candidate blocks that meet the PoW difficulty target.

[0051] Furthermore, the consensus node obtains the PoW difficulty target D that it needs to calculate under the current number of pledged shares S in this round of consensus cycle from the smart contract. 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 number of pledged shares corresponding to the PoW difficulty target, and then write the pledged share number 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.

[0052] Step S400: 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.

[0053] The consensus node broadcasts the candidate block to the entire network, and other nodes will verify the legitimacy of the 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, 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 transaction in the candidate block does not conflict with the local ledger state, the candidate block passes the legitimacy verification and is saved. The candidate block will be accepted by all users as a valid block, and the candidate block will be added to the blockchain. If the candidate block is illegal, the candidate block will be discarded.

[0054] If the candidate block passes the verification, the weight function can be updated based on the dynamic difficulty adjustment mechanism to gradually control the impact of the change in the amount of pledged equity on the PoW difficulty target; then based on the updated weight function, the block difficulty target of the next block-producing node is adjusted to end the consensus cycle. In the next round of consensus cycle, the weight function obtained by each node through the pledged equity will be recalculated. Specifically, the dynamic difficulty adjustment mechanism of this embodiment The formula is: , in, is the current block height, is a constant, is an enumeration variable, used to represent different blocks in sequence. is the initial pledged equity amount, For The amount of pledged equity changes that occurred at the time is a weight function used to control the impact of pledged equity changes on the PoW difficulty target. The weight function of this embodiment can adopt the following piecewise function: , or, .

[0055] It can be seen that this embodiment applies the method of dynamic difficulty adjustment mechanism to the blockchain evidence storage system, so that the dynamic changes in the number of pledged shares have a gradual impact on the blockchain evidence storage system, avoiding instantaneous changes in the difficulty of producing blocks. Compared with the traditional consensus mechanism, this implementation takes into account the dynamic changes in the number of pledged shares and its gradual impact on computing power and block difficulty. It is fairer and more decentralized, attracting more users to participate in the entire system, avoiding the problem of equity centralization caused by PoS, and avoiding the waste of resources 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 difficulty adjustment algorithm, which dynamically adjusts the PoW / PoS weight according to the dynamic distribution of the number of pledged shares, transaction load and security threats, thereby balancing the block difficulty targets of each block node in the blockchain evidence storage system, which is more stable and secure, and takes fairness into account.

[0056] In this embodiment, during the consensus cycle, the smart contract will record the node address of the pledge, the number of pledged shares, the PoW difficulty target, and the node status information. After the consensus cycle ends, the execution node in the blockchain evidence storage system executes all the packaged transactions in the candidate block, that is, executes the evidence request. After the execution is completed, the state information of all nodes on the blockchain is persistently stored and updated, and the current round of interaction process ends. In actual application, 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 persistently store 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 the equity transfer on the blockchain. After the execution engine executes these two transactions, the equity balances of the nodes involved in these two transactions will be updated and re-persistently stored on the blockchain.

[0057] In summary, the present invention constructs a two-way constrained hybrid consensus architecture by directly coupling the number of pledged shares of the node to the calculation of the PoW difficulty target, which not only suppresses the trend of wealth concentration of pure PoS, but also avoids the problem of waste of computing power of pure PoW, and significantly improves the openness and fairness of the network. In addition, the present invention applies the method of dynamic difficulty adjustment mechanism to the blockchain evidence storage system, which is fairer and more decentralized than the traditional consensus mechanism, while avoiding waste of resources and attracting more users to participate in the entire system.

[0058] Based on the above embodiment, the present invention also provides a blockchain evidence storage system based on a hybrid consensus algorithm, which is used to implement the steps in the above method embodiment, such as Figure 4As shown, the system includes: a block node 10, a smart contract 20, a candidate block acquisition module 30, and a block difficulty adjustment module 40. Specifically, the block node 10 pledges a certain amount of equity and generates a local blockchain initial structure based on packaged transactions at the beginning of the consensus cycle; the smart contract 20 determines the PoW difficulty target of the block node under the pledged equity amount based on the hybrid consensus algorithm; the candidate block acquisition module 30 is used to obtain candidate blocks that meet the PoW difficulty target; the block difficulty adjustment module 40 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.

[0059] In one implementation, the system further includes an execution node for executing all packaged transactions in the candidate block, and after the execution is completed, persistently storing and updating all node status information on the blockchain.

[0060] The working principles of each module in the blockchain evidence storage system based on the hybrid consensus algorithm of this embodiment are the same as the principles of each step in the above method embodiment, and will not be repeated here.

[0061] Each module in the blockchain evidence storage system based on the hybrid consensus algorithm can be implemented in whole or in part through software, hardware and their combination. Each module can be embedded in or independent of the processor in the terminal in the form of hardware, or can be stored in the memory in the terminal in the form of software, so that the processor can call and execute the corresponding operations of each module.

[0062] Based on the above embodiment, the present invention further provides a terminal, the principle block diagram of the terminal can be as follows: Figure 5 The terminal may include one or more processors 100 ( Figure 5 Only one is shown in the figure), memory 101 and computer program 102 stored in memory 101 and executable on one or more processors 100. For example, a blockchain evidence program based on a hybrid consensus algorithm. When one or more processors 100 execute computer program 102, each step in the embodiment of the blockchain evidence method based on a hybrid consensus algorithm can be implemented. Alternatively, when one or more processors 100 execute computer program 102, the functions of each module / unit in the embodiment of the blockchain evidence system based on a hybrid consensus algorithm can be implemented, which is not limited here.

[0063] In one embodiment, the processor 100 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0064] In one embodiment, the memory 101 may be an internal storage unit of an electronic device, such as a 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 an internal storage unit of the electronic device and an external storage device. The memory 101 is used to store computer programs and other programs and data required by the terminal. The memory 101 may also be used to temporarily store data that has been output or is to be output.

[0065] Those skilled in the art will understand that Figure 5 The principle block diagram shown in the figure is only a block diagram of a partial structure related to the scheme of the present invention, and does not constitute a limitation on the terminal to which the scheme of the present invention is applied. The specific terminal may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0066] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and 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-mentioned methods. Among them, any reference to memory, storage, operating database or other media used in the embodiments provided by the present invention may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double operational data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0067] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions 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; 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.

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 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.

4. The blockchain evidence storage method based on the hybrid consensus algorithm according to claim 3 is characterized in that: 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 The total amount of equity pledged by all block-producing nodes, is the pledge adjustment factor, 0< <1, is the adjustment factor for successfully mining a block, 0< <1, The number of blocks mined recently by the block-producing node.

5. The blockchain evidence storage method based on the hybrid consensus algorithm according to claim 4 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: Set a decay factor for the number of blocks mined by the block-producing node and set up a dynamic adjustment mechanism for the number of valid pledged shares ; Based on the attenuation factor and the dynamic adjustment mechanism Adjusting the hybrid consensus algorithm formula; The adjusted hybrid consensus algorithm formula is: in, is the number of dynamic and effective pledged shares of the block-producing node, It is mined from the block node The number of blocks mined by other block-producing nodes since blocks, The decay factor of the number of blocks mined by each block-producing node, 0< <1, N is the upper limit of the number of blocks mined by other nodes.

6. 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.

7. The blockchain evidence storage method based on the hybrid consensus algorithm according to claim 6 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.

8. The blockchain evidence storage method based on the hybrid consensus algorithm according to claim 7 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.

9. The blockchain evidence storage method based on the hybrid consensus algorithm according to claim 8 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.

10. The blockchain evidence storage method based on a hybrid consensus algorithm according to claim 5 or 9, characterized in that: The formula for the dynamic difficulty adjustment mechanism is: , in, , or, , in, is the current block height, is a constant, is an enumeration variable, used to represent different blocks in sequence. is the initial pledged equity amount, For The change in pledged equity at the time of It is a weight function used to control the impact of changes in pledged equity on the PoW difficulty target.

11. 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.

12. The blockchain evidence storage method based on the hybrid consensus algorithm according to claim 11 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.

13. The blockchain evidence storage method based on the hybrid consensus algorithm according to claim 12 is characterized in that ,The execution node is a consensus node.

14. 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 13, 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.

15. The blockchain evidence storage system based on the hybrid consensus algorithm according to claim 14 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.

16. 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 13 are implemented.

17. 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 13 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