Blockchain consensus method and system against double-spending attack based on block history contribution
By adjusting the block-producing history contribution and difficulty adjustment coefficient of blockchain nodes, the double-spending attack problem in the blockchain system is solved, and the security and stability of blockchain transactions are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING UNIV OF POSTS & TELECOMM
- Filing Date
- 2023-05-24
- Publication Date
- 2026-06-09
Smart Images

Figure CN116633621B_ABST
Abstract
Description
(I) Technical Field
[0001] This invention relates to the field of computer network technology, and in particular to a blockchain consensus method and system based on block history contributions to resist double-spending attacks. (II) Background Technology
[0002] Blockchain implements a distributed ledger, enabling nodes to manage trusted data and ensure consistency in value transactions in distributed scenarios lacking centralized trust. Participants collaborate to maintain the system's operation and periodically elect nodes through a consensus protocol to write new transaction data into the ledger. The ledger is composed of blocks containing transaction records chained together cryptographically. Because each block contains the content of the previous block, modifying the data in previous blocks becomes extremely difficult. Therefore, blockchain technology possesses characteristics such as decentralization, tamper-proof nature, and transaction traceability.
[0003] Nodes compete for the right to create blocks in a blockchain. In blockchains using Proof-of-Work (PoW) consensus, nodes competing to create blocks exhaustively solve a pre-defined mathematical problem using their computing power, continuously performing calculations and generating random numbers until the generated random number satisfies the requirements of the blockchain's mathematical problem. The node that solves the problem gains the right to create the next block. Each block contains transaction data. For each subsequent block, the confirmation count increments by 1. When the confirmation count reaches or exceeds a set block confirmation threshold, the transactions in that block are generally considered relatively secure and difficult to reverse.
[0004] Currently, blockchains based on Proof-of-Work consensus are vulnerable to double-spending attacks, where the same cryptocurrency can be spent multiple times. Taking Bitcoin, a typical example of Proof-of-Work consensus: ① An attacker's address 1 initiates transaction A, transferring cryptocurrency to a victim; ② After transaction A receives confirmation from subsequent blocks that meet or exceed a set block confirmation threshold, the victim approves transaction A and transfers cash or goods to the attacker; ③ The attacker's address 1 initiates transaction B, transferring cryptocurrency to address 2. The transaction amount is the total cryptocurrency in the attacker's address 1. Because transaction A conflicts with transaction B, the blockchain forks; ④ The attacker, leveraging their computing power advantage, generates a number of subsequent blocks that ensure transaction B receives confirmations exceeding the threshold, and the length of the blockchain containing transaction B exceeds the length of the chain containing transaction A. According to the longest chain principle, transaction B is considered valid, while transaction A is considered invalid, and the attacker successfully achieves a double-spending attack. (III) Summary of the Invention
[0005] To address the aforementioned issues, this invention provides a blockchain consensus method based on block production history contributions to resist double-spending attacks.
[0006] In a first aspect, embodiments of the present invention provide a blockchain consensus method for resisting double-spending attacks based on block production history contributions, comprising: a blockchain node calculating the difficulty of proof-of-work for generating a new block based on a threshold number of blocks recently stored on the blockchain; the more blocks generated by the blockchain node among the threshold number of blocks recently stored on the blockchain, the greater the difficulty of proof-of-work for generating a new block; the blockchain node calculating a block production difficulty adjustment coefficient based on its block production history contributions, such that the difficulty adjustment coefficient is lower when the blockchain node's block production history contributions are not higher than a low threshold or higher than a high threshold, and higher when the difficulties are higher than a low threshold but not higher than a high threshold; the blockchain node calculating a target difficulty value for proof-of-work based on the difficulty of proof-of-work and the block production difficulty adjustment coefficient, solving for a random value that makes the block header hash value of the new block less than the target difficulty value, and then broadcasting the new block; and the blockchain node storing the new block in the blockchain after verifying the received new block.
[0007] Furthermore, the block-producing history contribution of a blockchain node is the proportion of the number of blocks generated by the blockchain node to the total number of blocks in the blockchain.
[0008] Furthermore, the verification of the received new block includes:
[0009] Verify that the data format and length of the new block meet the block format and length requirements; if they do not, the verification fails.
[0010] Verify the validity of all transactions within the new block; if they do not comply, the verification fails.
[0011] Verify whether the block header hash value of the new block is less than the difficulty target value of the proof-of-work; if it does not, the verification fails.
[0012] Secondly, embodiments of the present invention provide a blockchain consensus system based on block history contributions to resist double-spending attacks, comprising: a difficulty calculation module, used by blockchain nodes to calculate the difficulty target value of proof-of-work for generating new blocks; a solution module, used by blockchain nodes to solve for a random value that makes the block header hash value of the new block less than the difficulty target value of proof-of-work, and broadcast the new block; and a verification module, used by blockchain nodes to store the new block in the blockchain after verifying the received new block.
[0013] Thirdly, embodiments of the present invention provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the steps of the blockchain consensus method based on block history contribution to resist double-spending attacks according to the first aspect of the present invention.
[0014] Fourthly, embodiments of the present invention provide a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of a blockchain consensus method based on block history contributions to resist double-spending attacks according to the first aspect of the present invention. (iv) Description of the attached drawings
[0015] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0016] Figure 1 A flowchart of a blockchain consensus method for resisting double-spending attacks based on block production history contributions, provided in an embodiment of the present invention;
[0017] Figure 2 This is a structural diagram of a blockchain consensus system based on block history contributions to resist double-spending attacks, provided in an embodiment of the present invention.
[0018] Figure 3 This is a schematic diagram of the physical structure of an electronic device provided in an embodiment of the present invention. (V) Detailed Implementation
[0019] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0020] Blockchain implements a distributed ledger, enabling nodes to manage trusted data and ensure consistent value transactions in distributed scenarios lacking centralized trust. Consensus based on Proof-of-Work (PoW) involves nodes using their computing power to solve a pre-defined mathematical problem by exhaustively generating random numbers. This process continues until a random number satisfies the blockchain's mathematical problem requirements. The node that first solves the problem gains the right to produce the next block. Each block contains transaction data. For each subsequent block, the confirmation count increments by 1. When the confirmation count reaches a set threshold, the transactions in that block are generally considered secure and difficult to reverse. Different blockchains have different confirmation thresholds; Bitcoin requires 6 confirmations, while Ethereum requires 12. Blockchains based on Proof-of-Work consensus are vulnerable to double-spending attacks, where the same cryptocurrency is spent multiple times. An attacker, to carry out a double-spending attack, initiates a first transaction and then a second transaction that conflicts with the first transaction's spending. In order to get the blockchain to recognize the second transaction, the attacker uses its computing power advantage to generate subsequent blocks with a confirmation count that reaches or exceeds a set confirmation threshold. This makes the length of the blockchain containing the second transaction exceed the length of the chain containing the first transaction. According to the longest chain principle, the second transaction is valid, while the first transaction A is considered invalid. The attacker successfully performs a double-spending attack.
[0021] To prevent double-spending attacks, it's necessary to increase the block difficulty for attackers with a computing power advantage, making it difficult or impossible for them to generate subsequent blocks with a confirmed number reaching a set threshold. The more blocks a particular blockchain node generates within the recently stored threshold number of blocks, the greater the difficulty for it to generate new blocks. To avoid increasing the difficulty of generating new blocks, blockchain nodes attempting double-spending attacks will change their identities or accounts to ensure that the difficulty of generating new blocks does not increase. This is addressed through a difficulty adjustment coefficient. When a blockchain node changes its identity or account, its block-generating history contribution is low and does not exceed a set low threshold, resulting in a lower difficulty adjustment coefficient. For blockchain nodes attempting double-spending attacks, which have the ability to generate subsequent blocks with a confirmed number reaching the set threshold and possess a computing power advantage, their block-generating history contribution is also high when using their original identity or account; therefore, when their block-generating history contribution exceeds a high threshold, their difficulty adjustment coefficient is lower. For normal blockchain nodes that are constantly solving the proof-of-work difficulty target value and maintaining the blockchain operation, their block production history contribution is higher than the low threshold but not higher than the high threshold, so their difficulty adjustment coefficient is relatively high. Blockchain consensus methods based on block production history contribution prevent double-spending attacks by adjusting the difficulty of the proof-of-work for generating new blocks and the block production difficulty adjustment coefficient.
[0022] Figure 1 A flowchart of a blockchain consensus method for resisting double-spending attacks based on block history contributions provided in this embodiment of the invention is shown below. Figure 1 As shown, this embodiment of the invention provides a blockchain consensus method based on block history contributions to resist double-spending attacks, including:
[0023] 101. Based on the information of a threshold number of blocks recently stored on the blockchain, the blockchain node calculates the difficulty of the proof-of-work for generating a new block. The more blocks generated by the blockchain node among the threshold number of blocks recently stored on the blockchain, the greater the difficulty of the blockchain node in generating a new block.
[0024] To earn rewards, blockchain nodes exhaustively solve a pre-defined mathematical problem using their computing power. The node that solves the problem gains the right to produce the next block and receives the reward. The blockchain system periodically adjusts the difficulty of solving this pre-defined mathematical problem; this difficulty is the same for all blockchain nodes. To carry out a double-spending attack, an attacker, after initiating a transaction that conflicts with the first transaction and a second transaction with a conflicting spending, needs to generate blocks with a confirmation count exceeding a set threshold in the block containing the second transaction. In different blockchains, Bitcoin requires 6 confirmations, and Ethereum requires 12. Therefore, to prevent double-spending, the block difficulty for attackers with computing power needs to be increased, making it difficult or impossible to generate subsequent blocks with a confirmation count exceeding the set threshold. The more blocks a particular blockchain node generates within a threshold number of recently stored blocks on the blockchain, the more difficult it becomes to generate new blocks. In other words, the lower the target value of the proof-of-work difficulty for that blockchain node to generate new blocks, the greater the difficulty for that blockchain node to solve for a random value that makes the block header hash value of the new block less than the target value of the proof-of-work difficulty.
[0025] For example, when blockchain node i produces a new block, the difficulty of producing the new block is difficulty(i):
[0026]
[0027] Where, basedifficult is the difficulty of solving a pre-defined mathematical problem in the blockchain system, w is the threshold number of blocks recently stored on the blockchain, n(i) is the number of blocks recently stored on the blockchain generated by blockchain node i, and μ is the block difficulty adjustment factor.
[0028] 102. The blockchain node calculates the block difficulty adjustment coefficient based on its contribution to the block production history. When the blockchain node's contribution to the block production history is not higher than a low threshold or is higher than a high threshold, the difficulty adjustment coefficient is low. When the contribution is higher than the low threshold but not higher than the high threshold, the difficulty adjustment coefficient is high.
[0029] The blockchain system adjusts the proof-of-work difficulty for blockchain nodes to generate new blocks based on a threshold number of recently stored blocks. If a blockchain node that has performed a double-spending attack is among the threshold number of recently stored blocks, the difficulty for that node to generate a new block will increase. Therefore, the node performing the double-spending attack will change its identity or account to ensure that the difficulty of generating a new block does not increase.
[0030] When a blockchain node committing a double-spending attack changes its identity or account, its block production history contribution is low and does not exceed a set low threshold, resulting in a lower difficulty adjustment coefficient. Conversely, for normal blockchain nodes that are consistently solving the difficulty target value for proof-of-work computation and maintaining blockchain operation, their block production history contribution is higher than the low threshold but not higher than the high threshold, resulting in a higher difficulty adjustment coefficient. For a blockchain node committing a double-spending attack, it has the capability to generate subsequent blocks with a confirmation count reaching or exceeding the set block confirmation threshold, possessing a computing power advantage. When it retains its original identity or account, its block production history contribution is also high; therefore, when its block production history contribution exceeds the high threshold, its difficulty adjustment coefficient is lower.
[0031] For example, the historical block contribution c(i) of blockchain node i:
[0032]
[0033] Where x(i) is the number of blocks generated by blockchain node i, and l is the total number of blocks on the blockchain.
[0034] For example, the difficulty adjustment coefficient adj(i) for blockchain node i:
[0035]
[0036] Where a and b are the parameters of the logistic regression function, adjusting the low and high thresholds. A lower difficulty adjustment coefficient is achieved when the historical block contribution of a blockchain node is no higher than the low threshold or higher than the high threshold; conversely, a higher difficulty adjustment coefficient is achieved when the contribution is higher than the low threshold but not higher than the high threshold.
[0037] 103. The blockchain node calculates the target difficulty value of the proof-of-work based on the difficulty of the proof-of-work and the block difficulty adjustment coefficient, solves for a random value that makes the block header hash value of the new block less than the target difficulty value, and then broadcasts the new block.
[0038] The blockchain node calculates the target difficulty value for the proof-of-work based on the difficulty of the proof-of-work and the block difficulty adjustment coefficient. The target difficulty value target(i) for the proof-of-work that blockchain node i needs to solve is:
[0039]
[0040] Where γ is the weight of the difficulty adjustment coefficient adj(i) of blockchain node i. The higher the difficulty(i) of blockchain node i in generating a new block or the lower the difficulty adjustment coefficient adj(i), the smaller the difficulty target value target(i) of proof-of-work will be. In other words, the smaller the range of random values that blockchain node i can solve to make the block header hash value of the new block less than the difficulty target value target of proof-of-work will be, and the greater the difficulty of blockchain node i solving for the random value target value target of proof-of-work will be.
[0041] Once a blockchain node has solved the problem of finding a random value that makes the hash value of the block header of the new block less than the difficulty target value of the proof-of-work, it broadcasts the new block to the other nodes in the blockchain.
[0042] 104. After a blockchain node verifies a new block it has received, it stores the new block in the blockchain.
[0043] Blockchain nodes verify the new blocks they receive, and once the verification is successful, they store the new blocks in the blockchain.
[0044] Based on the above embodiments, as an optional embodiment, the block production history contribution of a blockchain node is the proportion of the number of blocks generated by the blockchain node to the total number of blocks in the blockchain.
[0045] Blocks in a blockchain are generated by different blockchain nodes. The proportion of blocks generated by a blockchain node to the total number of blocks in the blockchain is used as the historical contribution of the blockchain node in terms of block generation.
[0046] Based on the above embodiments, as an optional embodiment, the verification of the received new block includes:
[0047] Verify that the data format and length of the new block meet the block format and length requirements; if they do not, the verification fails.
[0048] Verify the validity of all transactions within the new block; if they do not comply, the verification fails.
[0049] Verify whether the block header hash value of the new block is less than the difficulty target value of the proof-of-work; if it does not, the verification fails.
[0050] The requesting node needs to send a block containing transactions, conforming to the data format defined by the blockchain and meeting the difficulty target value for proof-of-work. The blockchain nodes need to verify the data format and length of the received block, as well as the content of all transactions within the new block. Each blockchain node knows which nodes generated the most recently stored threshold number of blocks on the blockchain, and knows the difficulty target value of the proof-of-work generated by that node. It also verifies whether the block header hash value of the new block is less than the difficulty target value for proof-of-work.
[0051] Figure 2 The following is a diagram of the blockchain consensus system architecture based on block history contributions to resist double-spending attacks, as provided in the embodiments of the present invention. Figure 2 As shown, this blockchain consensus system based on block production history contributions and resistant to double-spending attacks includes: a difficulty calculation module 201, a difficulty adjustment module 202, a solution module 203, and a verification module 204. Specifically, the difficulty calculation module 201 is used by blockchain nodes to calculate the difficulty of the proof-of-work for generating new blocks based on a threshold number of recently stored blocks on the blockchain; the difficulty adjustment module 202 is used by blockchain nodes to calculate a block production difficulty adjustment coefficient based on their block production history contributions; the solution module 203 is used by blockchain nodes to calculate a target difficulty value for the proof-of-work based on the difficulty and the block production difficulty adjustment coefficient, and then solve for a random value that makes the block header hash value of the new block less than the target difficulty value before broadcasting the new block; the verification module 204 is used by blockchain nodes to store the new block in the blockchain after verifying its validity.
[0052] The system embodiments provided in this invention are for implementing the above-described method embodiments. For specific processes and details, please refer to the above-described method embodiments, which will not be repeated here.
[0053] The blockchain consensus system based on block history contributions provided in this invention can prevent blockchain nodes from launching double-spending attacks. To launch a double-spending attack, an attacker first initiates a first transaction, and then initiates a second transaction with a conflicting cost. To gain blockchain acceptance for the second transaction, the attacker uses their computing power advantage to generate subsequent blocks with a confirmation count reaching a set threshold or higher. This causes the length of the blockchain containing the second transaction to exceed the length of the chain containing the first transaction. According to the longest chain principle, the second transaction is valid, while the first transaction A is considered invalid, and the attacker successfully launches a double-spending attack. Therefore, to prevent double-spending attacks, it is necessary to increase the block production difficulty for attackers with computing power advantages, making it difficult or impossible for them to generate subsequent blocks with a confirmation count reaching the set block confirmation threshold or higher. The more blocks a particular blockchain node generates in the most recently stored threshold number of blocks, the greater the difficulty for it to generate new blocks. To avoid increasing the difficulty of generating new blocks, blockchain nodes launching double-spending attacks will change their identities or accounts to ensure that the difficulty of generating new blocks does not increase. This is addressed through a difficulty adjustment coefficient. When a blockchain node changes its identity or account, its block production history contribution is low and does not exceed a set low threshold, resulting in a lower difficulty adjustment coefficient. For blockchain nodes attempting double-spending attacks, they have the capability to generate subsequent blocks with a confirmation count reaching or exceeding a set block confirmation threshold, possessing a computing power advantage. Even when using their original identity or account, their block production history contribution is high, therefore, when it exceeds a high threshold, their difficulty adjustment coefficient is low. Conversely, for normal blockchain nodes that consistently solve the difficulty target value for proof-of-work and maintain blockchain operation, their block production history contribution is higher than the low threshold but not higher than the high threshold, resulting in a higher difficulty adjustment coefficient. Blockchain consensus methods based on block production history contribution prevent double-spending attacks by adjusting the difficulty of generating new blocks' proof-of-work and the block difficulty adjustment coefficient.
[0054] Figure 3 This is a schematic diagram of the physical structure of an electronic device provided in an embodiment of the present invention, such as... Figure 3As shown, the electronic device may include a processor 301, a communication interface 302, a memory 303, and a bus 304. The processor 301, communication interface 302, and memory 303 communicate with each other via the bus 304. The communication interface 302 can be used for information transmission within the electronic device. The processor 301 can invoke logical instructions in the memory 303 to execute the following methods: A blockchain node calculates the difficulty of generating a new block's proof-of-work based on a threshold number of recently stored blocks on the blockchain; the more blocks generated by the blockchain node among the threshold number of recently stored blocks, the greater the difficulty of generating a new block's proof-of-work; the blockchain node calculates a block difficulty adjustment coefficient based on its historical block contribution, such that the difficulty adjustment coefficient is lower when its historical block contribution is not higher than a low threshold or higher than a high threshold, and higher when it is higher than a low threshold but not higher than a high threshold; the blockchain node calculates a target difficulty value for the proof-of-work based on the proof-of-work difficulty and the block difficulty adjustment coefficient, solves for a random value that makes the block header hash value of the new block less than the target difficulty value, and then broadcasts the new block; after verifying the received new block, the blockchain node stores the new block in the blockchain.
[0055] Furthermore, the logical instructions in the aforementioned memory 303 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the above-described method embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0056] On the other hand, embodiments of the present invention also provide a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program is implemented to perform the transmission methods provided in the above embodiments, including, for example, the following: a blockchain node calculates the difficulty of the proof-of-work for generating a new block based on a threshold number of blocks recently stored on the blockchain; the more blocks generated by the blockchain node among the threshold number of blocks recently stored on the blockchain, the greater the difficulty of the proof-of-work for generating a new block; the blockchain node calculates a block difficulty adjustment coefficient based on its contribution to the block production history, such that the difficulty adjustment coefficient is lower when the blockchain node's contribution to the block production history is not higher than a low threshold or higher than a high threshold, and higher when it is higher than a low threshold but not higher than a high threshold; the blockchain node calculates a target difficulty value for the proof-of-work based on the difficulty of the proof-of-work and the block difficulty adjustment coefficient, solves for a random value that makes the block header hash value of the new block less than the target difficulty value, and then broadcasts the new block; after the blockchain node verifies the received new block, it stores the new block in the blockchain.
[0057] The system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0058] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0059] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions 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 consensus method based on block history contributions to resist double-spending attacks, characterized in that, include: Based on a threshold number of blocks recently stored on the blockchain, the blockchain node calculates the difficulty of proving the work of generating a new block. The more blocks generated by the blockchain node from the threshold number of blocks recently stored on the blockchain, the greater the difficulty of proving the work of generating a new block. The blockchain node calculates the block difficulty adjustment coefficient based on its contribution to the block production history. When the blockchain node's contribution to the block production history is not higher than a low threshold or is higher than a high threshold, the difficulty adjustment coefficient is low. When the contribution to the blockchain node's block production history is higher than a low threshold but not higher than a high threshold, the difficulty adjustment coefficient is high. The blockchain node calculates the target difficulty value of the proof-of-work based on the difficulty of the proof-of-work and the block difficulty adjustment coefficient. The higher the difficulty of the proof-of-work or the lower the block difficulty adjustment coefficient, the smaller the target difficulty value. After the blockchain node solves for a random value that makes the block header hash value of the new block less than the target difficulty value, it broadcasts the new block. Once a blockchain node verifies a new block it has received, it stores the new block in the blockchain.
2. The blockchain consensus method for resisting double-spending attacks based on block history contributions according to claim 1, characterized in that, The block-producing history contribution of a blockchain node is the proportion of the number of blocks generated by that blockchain node relative to the total number of blocks in the blockchain.
3. The blockchain consensus method for resisting double-spending attacks based on block production history contributions according to claim 1, characterized in that, Verification of newly received blocks includes: Verify that the data format and length of the new block meet the block format and length requirements; if they do not, the verification fails. Verify the validity of all transactions within the new block; if they do not comply, the verification fails. Verify whether the block header hash value of the new block is less than the difficulty target value of the proof-of-work; if it does not, the verification fails.
4. A blockchain consensus system resistant to double-spending attacks based on block history contributions, characterized in that, include: The difficulty calculation module is used by blockchain nodes to calculate the difficulty of the proof-of-work for generating new blocks based on information about a threshold number of blocks recently stored on the blockchain. The difficulty adjustment module is used by blockchain nodes to calculate the block difficulty adjustment coefficient of the blockchain node based on its contribution in the block production history. The solution module is used by blockchain nodes to calculate the target difficulty value of proof-of-work based on the difficulty of proof-of-work and the block difficulty adjustment coefficient. The greater the difficulty of proof-of-work or the smaller the block difficulty adjustment coefficient, the smaller the target difficulty value. After the blockchain node solves for a random value that makes the block header hash value of the new block less than the target difficulty value, it broadcasts the new block. The verification module is used by blockchain nodes to store the new block in the blockchain after the new block has been verified.
5. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the blockchain consensus method for resisting double-spending attacks based on block history contributions as described in any one of claims 1 to 3.
6. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the steps of the blockchain consensus method based on block history contributions to resist double-spending attacks as described in any one of claims 1 to 3.