Blockchain consensus mechanism execution method and device

By introducing a deposit and reward/penalty mechanism into the blockchain DPoS consensus through smart contracts, the problems of slow block generation speed, high cost, and insufficient node enthusiasm are solved, and a safe and efficient consensus operation is achieved.

CN115423623BActive Publication Date: 2025-12-30BEIJING UNIV OF POSTS & TELECOMM +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211014730.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-23
Publication Date
2025-12-30
Estimated Expiration
2042-08-23

AI Technical Summary

Technical Problem

The existing blockchain DPoS consensus mechanism suffers from problems such as slow block generation speed, high operating costs, difficulty in troubleshooting faulty nodes, and insufficient node participation.

Method used

A smart contract mechanism is adopted, which uses the reward money of candidate nodes as a deposit, selects representative nodes based on the voting contract, records the number of blocks produced and the amount of reward money after block production, executes the reward contract to distribute rewards, and handles abnormal nodes through the penalty contract, thus designing a voting and accounting reward mechanism.

Benefits of technology

It increases the enthusiasm of nodes to participate in consensus operations, promptly removes abnormal nodes, reduces operating costs, prevents malicious control, and ensures system security and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115423623B_ABST
    Figure CN115423623B_ABST
Patent Text Reader

Abstract

The application provides a blockchain consensus mechanism execution method and device, requires a participating representative node to provide a guarantee in a competition and working process, loads and executes a reward contract by using a smart contract, provides a voting reward scheme for each node, provides a voting reward for a common node participating in voting, provides an accounting reward for an accounting behavior of the representative node, and improves the enthusiasm of each node participating in a consensus operation. Meanwhile, the smart contract is used to load and execute a punishment contract, the abnormal representative node is kicked out of the committee and the guarantee, the voting reward and the accounting reward are deducted on the basis of delaying the payment of the voting reward and the accounting reward, and the evil cost is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of blockchain technology, and in particular to a method and apparatus for implementing a blockchain consensus mechanism. Background Technology

[0002] Blockchain is a model for implementing and managing transaction processing in a peer-to-peer network environment. It constructs an unforgeable, immutable, and traceable block-chain data structure (based on timestamp order) through transparent and trustworthy rules. It is a novel application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms, possessing key characteristics such as distributed peer-to-peer, block-chain data structure, unforgeability and tamper-proof nature, and transparency and trustworthiness.

[0003] In a blockchain system, given a set of server nodes and a series of specified operations, a consensus is reached among the server nodes under the guarantee of a certain protocol. This protocol is called a consensus algorithm. Each consensus node in the blockchain verifies and confirms data according to a pre-defined consensus algorithm, negotiates the validity of transactions or blocks, reaches a consensus among nodes, and finally writes the valid data into the blockchain. Therefore, the performance and security of the consensus mechanism are important factors in evaluating its quality.

[0004] Currently, mainstream consensus algorithms include PoW, PoS, and DPoS (Delegated Proof of Stake). Compared to PoW and PoS, DPoS uses voting to elect representative nodes to verify and package transactions, reducing the number of block-producing nodes, resulting in faster verification and packaging speeds. It also does not rely on holding interest, thus reducing overall network operating costs and improving efficiency. However, DPoS also has its problems: when a representative node fails, it can only skip nodes to troubleshoot, making it impossible to promptly eliminate faulty nodes; and nodes lack motivation to participate in the election of representative nodes and vote for them. Summary of the Invention

[0005] In view of this, embodiments of the present invention provide a blockchain consensus mechanism execution method and apparatus to eliminate or improve one or more defects existing in the prior art, and solve the problems of slow block generation speed, high operating costs, difficulty in troubleshooting faulty nodes, and lack of enthusiasm of each node in the consensus mechanism caused by the current consensus mechanism.

[0006] One aspect of the present invention provides a method for executing a blockchain consensus mechanism, the method being based on the operation of smart contracts on a blockchain network, and comprising the following steps within a cycle:

[0007] It receives the staked reward funds from multiple candidate nodes participating in the election as collateral, receives the votes from each node in the blockchain network for the candidate node, and records the number of times each node participates in voting and the amount of reward funds held by each node.

[0008] Based on the voting contract, a set number of candidate nodes are selected as representative nodes, and the margin of the remaining candidate nodes is released.

[0009] After each representative node packages the transactions of ordinary nodes into blocks according to the agreed block production order, verifies them, and stores them on the chain, the block headers are queried to record the number of times each representative node has correctly produced a block and the amount of reward money pledged in the provided security deposit.

[0010] The reward contract is executed, and the voting reward for each node is calculated according to the first set rule based on the number of times each node participates in voting and the amount of reward funds held by each node; according to the second set rule, the accounting reward for each representative node is calculated according to the number of times each representative node correctly produces blocks and the amount of reward funds pledged in the provided security deposit, and the voting reward and the accounting reward are delayed until the end of the period for distribution.

[0011] Before distributing the voting reward and the accounting reward, a penalty contract is executed. If a representative node fails to produce a block for a set number of times and / or engages in malicious behavior, the representative node is kicked out and its corresponding deposit, voting reward, and accounting reward are deducted.

[0012] In some embodiments, the security deposit, the voting reward, and the accounting reward use a cryptographic proof generated based on the Ethernet ERC20 standard.

[0013] In some embodiments, the voting reward for each node is calculated according to a first set rule, based on the number of times each node participates in voting and the amount of reward funds held by each node, including:

[0014] The voting weight of the i-th node is calculated using the following formula:

[0015]

[0016] in, This represents the voting weight of the i-th node. This represents the weight of the reward tier held by the i-th node. Specifically, the node is divided into multiple weight tiers based on the amount of reward held. The more reward held by the node, the greater the weight of the corresponding reward tier. The number of times the i-th node participates in the vote;

[0017] The voting reward for the i-th node in the x-th voting round is calculated using the following formula:

[0018]

[0019] in, This represents the voting reward for the i-th node in the x-th voting round. This represents the total initial voting reward value for the first period; This represents the voting weight of the i-th node.

[0020] In some embodiments, when the smart contract records an abnormal node voting event, it controls the total voting reward value for the next cycle to be reduced by a set ratio.

[0021] In some embodiments, according to a second set rule, the accounting reward for each representative node is calculated based on the number of times each representative node correctly produces blocks and the amount of reward funds pledged in the provided margin, including:

[0022] The accounting reward weight for the i-th representative node in the current period is calculated using the following formula:

[0023]

[0024] in, This represents the accounting reward weight of the i-th representative node in the current period. and To adjust the coefficient, The i-th element represents the amount of reward funds pledged in the margin corresponding to the node. This represents the correct block count of the block packaged by the i-th representative node. Indicates the time compensation increment;

[0025] The accounting reward for the i-th representative node is calculated using the following formula:

[0026]

[0027] in, This represents the accounting reward for the i-th representative node. This represents the total value of the accounting rewards for the current period.

[0028] In some embodiments, the adjustment parameters and The initial value is 1, and it decreases as the number of cycles increases.

[0029] In some embodiments, the time compensation increment The quantity is adjusted upwards in line with the cycle within the range of 0.02 to 0.08.

[0030] In some embodiments, when a representative node fails to produce blocks for a set number of times and / or engages in malicious behavior, the representative node is removed and its corresponding deposit, voting reward, and accounting reward are deducted, including:

[0031] When a representative node fails to produce a block for a set number of times, and during the verification process, more than half of the representative nodes trigger the penalty contract, the representative node is kicked out and its corresponding deposit, voting reward, and accounting reward are deducted.

[0032] And / or, if a representative node packages transactions incorrectly or packages transactions out of order and puts them on the chain, during the verification process, if any representative node triggers the penalty contract, that representative node will be kicked out and its corresponding deposit, voting reward, and accounting reward will be deducted.

[0033] On the other hand, the present invention also provides a decentralized blockchain network system, comprising a blockchain network composed of multiple nodes, wherein smart contracts are executed on the blockchain network, and the smart contracts perform the steps of the above-described method.

[0034] On the other hand, the present invention also provides a computer-readable storage medium having a computer program stored thereon, characterized in that the program, when executed by a processor, implements the steps of the above-described method.

[0035] The beneficial effects of the present invention are at least as follows:

[0036] The blockchain consensus mechanism execution method and apparatus of this invention require participating representative nodes to provide a deposit during the election and work process. It utilizes a smart contract to load and execute a reward contract, providing a voting reward scheme for each node. This provides voting rewards for ordinary nodes participating in voting and accounting rewards for representative nodes' accounting activities, thereby increasing the enthusiasm of each node to participate in consensus operations. Simultaneously, it utilizes a smart contract to load and execute a penalty contract. In addition to delaying the distribution of voting and accounting rewards, it promptly removes abnormal representative nodes from the committee and deducts their deposits, voting rewards, and accounting rewards, increasing the cost of malicious behavior.

[0037] Furthermore, this invention calculates the number of votes held by each node based on the amount of reward funds held and the number of votes cast, which can prevent malicious nodes from controlling the election by registering a large number of accounts; it also ensures that honest nodes can obtain more voting rewards by actively participating in voting, and prevents large accounts from monopolizing the voting process.

[0038] Additional advantages, objects, and features of the invention will be set forth in part in the description which follows, and will also become apparent in part to those skilled in the art upon studying the description, or may be learned by practice of the invention. The objects and other advantages of the invention can be realized and obtained by means of the structures specifically pointed out in the specification and drawings.

[0039] Those skilled in the art will understand that the objectives and advantages achievable with this invention are not limited to those specifically described above, and that the above and other objectives achievable with this invention will become clearer from the following detailed description. Attached Figure Description

[0040] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, are not intended to limit the scope of the invention. The components in the drawings are not drawn to scale but are merely illustrative of the principles of the invention. For ease of illustration and description of certain parts of the invention, corresponding portions in the drawings may be enlarged, i.e., may appear larger relative to other components in an exemplary device actually manufactured according to the invention. In the drawings:

[0041] Figure 1 This is a flowchart illustrating the execution method of the blockchain consensus mechanism according to an embodiment of the present invention.

[0042] Figure 2 This is a schematic diagram illustrating the process of selecting representative nodes and producing blocks in the blockchain consensus mechanism execution method according to an embodiment of the present invention.

[0043] Figure 3 This is a schematic diagram of the process of penalty settlement after block production in the blockchain consensus mechanism execution method according to an embodiment of the present invention. Detailed Implementation

[0044] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the embodiments and accompanying drawings. Here, the illustrative embodiments and descriptions of this invention are used to explain the invention, but are not intended to limit the invention.

[0045] It should also be noted that, in order to avoid obscuring the invention with unnecessary details, only the structures and / or processing steps closely related to the solution according to the invention are shown in the accompanying drawings, while other details that are not closely related to the invention are omitted.

[0046] It should be emphasized that the term "including / comprises" as used herein refers to the presence of a feature, element, step, or component, but does not exclude the presence or addition of one or more other features, elements, steps, or components.

[0047] The main problems with the current DPoS consensus mechanism are: insufficient constraints on representative nodes, especially when representative nodes encounter problems and cannot be removed from the committee in a timely manner, affecting system efficiency; and the lack of a sound incentive mechanism, especially insufficient rewards for voting nodes, resulting in low enthusiasm for participating in voting.

[0048] To address the problems of DPoS, existing technologies combine DPoS with BFT (Byzantine Fault Tolerance), improving block generation efficiency but increasing the probability of electing malicious nodes, thus posing a security threat. Current common solutions involve adding reputation values ​​to representative nodes to remove problematic nodes. One existing DPoS improvement scheme uses credit rewards and penalties and voting results for selection, defining node status with credit to quickly remove faulty nodes, but it doesn't effectively reward voting nodes. Another existing improvement scheme based on credit and reward mechanisms can reduce the probability of abnormal nodes becoming proxies and their impact on the system, but it only relies on pre-election prevention for malicious nodes; once a node becomes malicious, the system struggles to cope.

[0049] This invention addresses the common problems in current mainstream DPoS mechanism improvements, such as incomplete incentive mechanisms and insufficient timeliness in removing faulty nodes. It designs a decentralized system based on an improved DPoS mechanism that operates on smart contracts. This system provides corresponding reward and punishment measures for both voting nodes and representative nodes, ensuring election security while rapidly removing faulty nodes. The system includes an incentive mechanism module and a DPoS mechanism module. The smart contract is treated as a trusted third party, and the voting and reward settlement processes are handled by the smart contract, ensuring system security and immutability. A cryptographic reward is issued using the Ethereum platform, and this reward is used to incentivize and punish node accounts, thereby constraining node behavior.

[0050] It should be noted beforehand that Ethereum, as discussed in this invention, is a decentralized, open-source public blockchain platform with smart contract functionality. It uses its dedicated cryptographic proof-of-stake, Ether, to provide a decentralized Ether Virtual Machine for processing peer-to-peer contracts. A smart contract is a special protocol used when creating contracts within a blockchain. It contains code functions and can interact with other contracts, make decisions, store data, and send Ether. Smart contracts allow for trusted transactions without a third party. These transactions are traceable and irreversible. Delegated Proof-of-Stake (DPoS) consensus, also known as a delegated proof-of-stake consensus mechanism, is similar to a board voting system. Stakeholders can use their stake as votes to select any number of N nodes with the highest vote percentages to form a delegate representative to generate data blocks. A P2P network is a distributed peer-to-peer network, a distributed application architecture that distributes tasks and workloads among peer-to-peer nodes. It is a network or grouping form of the peer-to-peer computing model at the application layer.

[0051] Specifically, this embodiment provides a method for executing a blockchain consensus mechanism. This method is based on the operation of smart contracts on a blockchain network. Within a cycle, such as... Figure 1 As shown, the method includes the following steps S101~S105:

[0052] In this embodiment, steps S101 to S105 are not a limitation on the order of the steps. It should be understood that, in a specific application scenario, the steps in this embodiment can be executed in parallel or in a different order.

[0053] Step S101: Receive the staked reward funds from multiple candidate nodes participating in the election as collateral, receive the votes from each node in the blockchain network for the candidate nodes, and record the number of times each node participates in voting and the amount of reward funds held by each node.

[0054] Step S102: Select a set number of candidate nodes as representative nodes based on the voting contract, and release the margin of the remaining candidate nodes.

[0055] Step S103: After each representative node packages the transactions of the ordinary nodes into blocks according to the agreed block production order and verifies them to be stored on the chain, query each block header and record the number of times each representative node correctly produces a block and the amount of reward money pledged in the provided security deposit.

[0056] Step S104: Execute the reward contract. According to the first set rule, calculate the voting reward for each node based on the number of times each node participates in voting and the amount of reward funds held by each node. According to the second set rule, calculate the accounting reward for each representative node based on the number of times each representative node correctly produces a block and the amount of reward funds pledged in the provided security deposit. Delay the distribution of the voting reward and accounting reward until the end of the cycle.

[0057] Step S105: Before distributing voting rewards and accounting rewards, execute the penalty contract. If a representative node fails to produce a block for a set number of times and / or engages in malicious behavior, kick out the representative node and deduct its corresponding deposit, voting rewards, and accounting rewards.

[0058] In steps S101 to S105, multiple nodes are connected in a P2P manner to form a blockchain network, and the smart contract executes the consensus scheme of the present invention based on the delegated proof-of-stake consensus mechanism.

[0059] To encourage active participation in voting by ordinary nodes in the blockchain network and to incentivize and constrain the accounting behavior of representative nodes, this invention proposes three requirements: first, ordinary nodes running for representative node positions must contribute a portion of their equity as a security deposit; second, a reward contract must be executed to reward the voting behavior of ordinary nodes and the accounting behavior of representative nodes; and third, a penalty contract must be executed to penalize abnormal block production behavior by representative nodes. The security deposit, voting rewards, and accounting rewards generated by the reward contract are all issued and traded using a single reward fund. In some embodiments, the reward fund used for the security deposit, voting rewards, and accounting rewards is a cryptographic proof generated based on the Ethernet ERC20 standard.

[0060] To this end, the present invention sets up a smart contract that includes and executes three parts of contract content: the first is a voting contract, which is used to perform the operation of voting to select representative nodes; the second is a reward contract, which is used to reward voting and accounting behavior; and the third is a penalty contract, which is used to punish abnormal block production behavior of representative nodes.

[0061] Specifically, in steps S101-S103, during the execution of the voting contract, ordinary nodes in the blockchain elect representative nodes qualified to generate data blocks based on their own stake, forming a committee. Each ordinary node can participate in the election as a candidate node, providing a deposit, to become a representative node. The deposit provided by the elected representative node is pledged in the smart contract throughout the voting and accounting process of the entire cycle and is only returned at the end of the cycle. During the election process, the deposits provided by candidate nodes that are not elected as representative nodes are returned after the voting ends.

[0062] In the general workflow, ordinary blocks handle transactions, and representative blocks package them in a pre-defined order. These packages are then verified by other representative nodes in the committee before being stored on the blockchain. Ordinary blocks can also verify the blocks they form. Smart contracts do not participate in this process; however, they check the signatures of the representative nodes that formed the block in the block header and count the number of times each representative node correctly produced a block. This count, combined with the amount of staked rewards provided, is used to calculate the accounting reward.

[0063] In step S104, when the smart contract executes the reward contract, it includes two parts: one is the voting reward for each node in each cycle, and the other is the accounting reward for the representative node in each cycle.

[0064] In some embodiments, in step S104, the voting reward for each node is calculated according to the first set rule based on the number of times each node participates in voting and the amount of reward funds held by each node, including steps S201 and S202:

[0065] Step S201: Calculate the voting weight of the i-th node, using the following formula:

[0066]

[0067] in, This represents the voting weight of the i-th node. This represents the weight of the reward tier held by the i-th node. Specifically, multiple weight tiers are divided according to the amount of reward held by the node. The more reward held by the node, the greater the weight of the corresponding reward tier. This represents the number of times the i-th node participates in voting.

[0068] Step S202: Calculate the voting reward for the i-th node in the x-th voting round, using the following formula:

[0069]

[0070] in, This represents the voting reward for the i-th node in the x-th voting round. This represents the total initial voting reward value for the first period; This represents the voting weight of the i-th node.

[0071] The voting reward calculation method provided in this embodiment comprehensively evaluates the voting performance of each ordinary node and assigns rewards accordingly. Firstly, voting weights are allocated differently based on the amount of reward funds held by each node, and secondly, weights are allocated based on the number of times a node votes. Specifically, the more reward funds a node holds and the more times it participates in voting, the higher its voting weight. Furthermore, the total value of the voting reward is fixed in each cycle for distribution among the nodes. As the number of cycles increases, the total value of the voting reward for each cycle is set to grow at an S-shaped curve to increase the reward value.

[0072] In some embodiments, when the smart contract detects an abnormal node voting activity, it controls the reduction of the total voting reward for the next cycle by a set percentage. Specifically, once the smart contract detects an abnormal node voting activity, the total voting reward for this round is reduced by a set percentage, such as 10%.

[0073] In some embodiments, when calculating the accounting reward in step S104, the accounting reward for each representative node is calculated according to the second set rule based on the number of times each representative node correctly produces blocks and the amount of reward money pledged in the provided margin, including steps S301 and S302:

[0074] Step S301: Calculate the accounting reward weight of the i-th representative node in the current period. The calculation formula is:

[0075]

[0076] in, This represents the accounting reward weight of the i-th representative node in the current period. and To adjust the coefficient, The i-th element represents the amount of reward funds pledged in the margin corresponding to the node. This represents the correct block count of the block packaged by the i-th representative node. This indicates the time compensation increment.

[0077] Step S302: Calculate the accounting reward for the i-th representative node, using the following formula:

[0078]

[0079] in, This represents the accounting reward for the i-th representative node. This represents the total value of the accounting rewards for the current period.

[0080] In this embodiment, the total value of the accounting reward for each period is fixed. The weight of the accounting reward received by each representative node is positively correlated with the amount of reward funds it provides for staking, the number of blocks it has correctly produced, and the duration of operation. The time compensation increment is used to incentivize block-producing nodes in the system to honestly complete their block-producing tasks over a long period. Therefore, the longer the time, the greater the weight of the additional reward. The time compensation increment can be set to a value that gradually increases with time. In some embodiments, the parameters are adjusted. and The initial value is 1, and it decreases as the number of periods increases. In some embodiments, the time compensation increment... The quantity is adjusted upwards in line with the cycle within the range of 0.02 to 0.08.

[0081] In step S104, voting rewards and accounting rewards adopt a delayed distribution mechanism. The design idea behind delayed reward distribution is to postpone the time when rewards should be distributed, and to punish any dangerous behavior of nodes discovered during this period. For voting nodes, rewards are not immediately received after the committee is elected; instead, they are automatically distributed by the contract when the system's reward phase arrives. For block-producing nodes, the block reward is not attached to each mined block, but only to the block record itself. The contract transfers the reward after the accounting period ends.

[0082] In step S105, the penalty contract is executed by the smart contract. When a representative node fails to produce a block for a set number of times and / or engages in malicious behavior, the representative node is kicked out and its corresponding deposit, voting reward, and accounting reward are deducted, including steps S1051~S1052:

[0083] Step S1051: When a representative node fails to produce a block for a set number of times, and during the verification process, more than 1 / 2 of the representative nodes trigger the penalty contract, the representative node is kicked out and its corresponding deposit, voting reward and accounting reward are deducted.

[0084] And / or, step S1052: when a representative node packages transactions incorrectly or packages transactions out of order and puts them on the chain, during the verification process, if any representative node triggers the penalty contract, the representative node is kicked out and its corresponding deposit, voting reward and accounting reward are deducted.

[0085] On the other hand, the present invention also provides a decentralized blockchain network system, comprising a blockchain network composed of multiple nodes, wherein smart contracts are executed on the blockchain network, and the smart contracts perform the steps of the above-described method.

[0086] On the other hand, the present invention also provides a computer-readable storage medium having a computer program stored thereon, characterized in that the program, when executed by a processor, implements the steps of the above-described method.

[0087] The present invention will now be described with reference to a specific embodiment:

[0088] This embodiment provides a decentralized blockchain system that implements the voting and reward components of the consensus mechanism in a smart contract, delaying the reward for the correct participation of representative nodes and voting nodes in the system operation; it designs an incentive mechanism, including reward and punishment units, which can monitor the behavior of representative nodes, promptly remove abnormal nodes from the representative node list, and impose penalties to prevent damage and impact on the system.

[0089] The decentralized system specifically refers to a blockchain system based on an improved DPoS consensus mechanism. In this system, numerous nodes elect a committee through voting. Representative nodes on the committee provide the functions of verifying and packaging transactions. An incentive mechanism rewards nodes with bonuses and deducts from their bonuses as penalties. To increase node participation, this embodiment designs a reward mechanism that provides rewards to committee representative nodes and participating voting nodes. Simultaneously, a penalty system is designed for representative nodes to ensure that the system can balance efficiency and security. These two mechanisms are collectively referred to as the incentive mechanism.

[0090] The entire system is divided into two modules and three parts. The two modules are the consensus mechanism module and the incentive mechanism module; the three parts include the voting phase, the accounting phase, and the reward phase. Rewards are the core of the system's operation. To distribute rewards to nodes within the system, this embodiment uses the Ethereum platform's ERC20 standard to design a cryptographic proof with functions such as querying, freezing, transferring, and authorizing. Nodes can use reward funds to purchase products and services provided by the system. Since the smooth operation of the entire system depends on the honest behavior of nodes in voting and block production, to regulate node behavior and incentivize more nodes to actively participate in system governance, this embodiment provides an incentive mechanism module, including a reward scheme and a penalty scheme.

[0091] First, to increase the cost of malicious behavior by representative nodes, this embodiment provides a deposit and delayed reward distribution scheme: During the election, nodes need to freeze a certain amount of reward funds in their accounts as a deposit. If the election fails, the deposit is released; if the election is successful, the deposit remains frozen until the reward settlement stage. If a node successfully becomes a representative node, the rewards obtained from verifying and packaging transactions are delayed until the reward stage, where a smart contract distributes the rewards according to our designed distribution standards, which are detailed below. Regarding abnormal behavior by representative nodes, this embodiment categorizes it into two types: one is offline behavior due to network anomalies or other reasons, resulting in no blocks being produced; the other is malicious behavior such as packaging incorrect transactions or packaging transactions out of order. Based on their behavior, a dual penalty scheme is adopted, involving kicking them out of the committee on-chain and deducting both their account deposit and rewards.

[0092] Specifically, to incentivize ordinary nodes within the system to actively participate in voting, this embodiment designs a voting reward scheme. The overall detailed scheme is as follows:

[0093] 1) Incentive Contract

[0094] 1. Voting Rewards: We designed a reward distribution strategy based on voting weight, calculated using the following formula. Nodes with higher weights receive more rewards. The total voting reward distribution is related to the performance of the representative nodes. When the representative nodes are recording transactions normally, the total voting reward value for each period increases at an S-shaped curve rate. Once an abnormal node is recorded in the contract, the total voting reward for that round is reduced by 10%.

[0095] The voting weight of the i-th node is calculated using the following formula:

[0096]

[0097] in, This represents the voting weight of the i-th node. This represents the weight of the reward tier held by the i-th node. Specifically, multiple weight tiers are divided based on the amount of reward funds held by the node. The more reward funds a node holds, the greater the weight of the corresponding reward tier. For example, the reward tiers are divided into 10 tiers, each assigned a weight value from 1 to 10. This represents the number of times the i-th node participates in voting.

[0098] The voting reward for the i-th node in the x-th voting round is calculated using the following formula:

[0099]

[0100] in, This represents the voting reward for the i-th node in the x-th voting round. This represents the total initial voting reward value for the first period; This represents the voting weight of the i-th node.

[0101] 2. Transaction Recording Rewards: Since the task of a representative node is to verify the correctness of transactions and package them, the distribution of transaction recording rewards is related to its performance in verifying and packaging transactions. The following allocation method is adopted for reward distribution. Default adjustment coefficient. , The initial value is 1, and it will be adjusted downwards based on the accounting cycle. The reward weight of a node consists of three parts: the proportion of staking rewards, the proportion of times it participates in block production, and the compensation weight for participation in accounting time. The reward for each node is distributed according to the proportion of these weights.

[0102] The accounting reward weight for the i-th representative node in the current period is calculated using the following formula:

[0103]

[0104] in, This represents the accounting reward weight of the i-th representative node in the current period. and To adjust the coefficient, The i-th element represents the amount of reward funds pledged in the margin corresponding to the node. This represents the correct block count of the block packaged by the i-th representative node. This represents the time compensation increment, with a default value of 0.05.

[0105] The accounting reward for the i-th representative node is calculated using the following formula:

[0106]

[0107] in, This represents the accounting reward for the i-th representative node. This represents the total value of the accounting rewards for the current period.

[0108] (ii) Penalty Contract

[0109] The penalty scheme is implemented through smart contracts deployed on the blockchain. Since the representative node is responsible for verifying, packaging transactions, and generating blocks, the honesty of the representative node is particularly important. This embodiment designs a penalty scheme to increase the severity of penalties for abnormal node behavior. First, during the election of representative nodes, to prevent malicious nodes from participating in the election and disrupting the system, it is stipulated that all nodes must pay a certain amount of deposit during the election, and the deposit cannot be used during the freeze period.

[0110] If a representative node experiences a crash or network anomaly during block production and fails to package transactions within the stipulated time, the next representative node will record the number of times it failed to produce a block and write it into the block. When a node fails to produce a block too many times, other representative nodes can choose to trigger a penalty contract. The contract stipulates that if more than half of the representative nodes trigger this event, the node will be removed from the representative node sequence and will no longer be responsible for block production. At the same time, its frozen deposit and reward will be deducted during the reward phase. If block production resumes normally or the penalty requirements are not met, the reward will be distributed normally according to the standard during the reward phase, and the deposit will be released.

[0111] If a representative node engages in malicious behavior, such as packaging incorrect transactions or uploading transactions out of order, the penalty contract will be triggered when other representative nodes fail verification. This will remove the node from the representative node sequence and synchronize the representative node sequence on-chain and in local storage. This node will be ineligible to participate in the election for a certain period, and all frozen margin and reward funds will be deducted during the reward phase.

[0112] This embodiment divides the system into three stages: voting stage, accounting stage, and reward stage, proceeding sequentially according to timestamps. The voting and reward stages are completed through voting contracts and reward contracts, respectively. The following is a detailed description of each stage:

[0113] 1.1 Voting Stage

[0114] First, the genesis block is initialized, the voting contract is deployed, and the current system cycle is initialized. Nodes broadcast their local addresses via a P2P network, update their routing tables, establish connections with other nodes, and the voting phase begins, during which transactions are suspended. Nodes participating in the election stake a portion of their reward funds to the smart contract, becoming candidates and receiving votes from other nodes. During this phase, ordinary nodes can query candidate information at any time through the voting contract and vote for candidates. The number of votes a voting node possesses is simultaneously recorded in the voting contract and used when settling voting rewards.

[0115] When the timer expires, the voting contract triggers a vote counting event, calculates the votes received by each candidate, and selects the top N candidates to join the committee as representative nodes, releasing the deposits of the other candidates. The voting contract automatically determines the accounting order through a shuffling algorithm, and the representative nodes synchronize this information with other nodes in the system. At this point, transactions are packaged in sequence, and the system enters the accounting phase.

[0116] 1.2 Bookkeeping Stage

[0117] Once the representative nodes are identified, the system enters the accounting phase. Regular nodes can perform transactions such as transferring funds and purchasing services. The representative node packages these transactions according to the agreed-upon block production order and adds its own signature. Other nodes are responsible for verifying the correctness of the blocks. When more than half of the nodes have verified that the blocks are correct, the block can be added to the blockchain, and regular nodes can check whether the block was successful.

[0118] If all delegate nodes are honest, the system will not fork. Delegate nodes locally store all transaction information and committee list information, while ordinary nodes only need to store block header information. This stage does not require smart contracts.

[0119] If abnormal behavior occurs during the time slice of a representative node, that node will be skipped, and the next node will continue block production. The penalty scheme in the incentive mechanism module will then apply to this node. The block header records the representative node's signature and the number of correct block productions, which are used during the reward phase.

[0120] 1.3 Reward Phase

[0121] After the accounting phase ends, the system enters the reward phase. First, the penalty contract is triggered, and based on the behavior of the representative node, the deposit and reward of the node that violated the rules are confiscated according to the penalty mechanism. Then, the reward contract is triggered, and the reward is distributed according to the reward contract, and the node's staked funds are released.

[0122] Once the rewards have been distributed, the node information within the blockchain system is updated synchronously, and the system automatically enters the next cycle.

[0123] Figure 2 , 3 This is a system structure diagram and data flow diagram of the present invention. The present invention uses the following technology: a DPoS consensus mechanism based on smart contracts: each registered node is bound to an Ethereum address, nodes are connected via a P2P network, and the Kademlia algorithm is used to query nodes in the network. The voting and reward phases in the mechanism are completed by voting contracts and incentive contracts. The incentive mechanism is executed by issuing cryptographic rewards through the Ethereum platform, and the incentive contracts (reward contracts and penalty contracts) in the module are implemented using smart contracts. The contracts are triggered based on the node's behavior to transfer, freeze, or deduct rewards from the node's account. The present invention solves the problem of insufficient incentives in the original DPoS mechanism, and can provide reward rewards to nodes within the system, providing a decentralized platform for different application scenarios.

[0124] Therefore, this invention improves the DPoS consensus mechanism of blockchain by designing a voting reward scheme to reward ordinary nodes for participating in system activities, thus solving the problem of unenthusiastic participation of voting nodes in the original consensus. It also improves the DPoS consensus mechanism by providing a penalty scheme: if a representative node exhibits abnormal behavior, it can be promptly removed from the committee, ensuring transaction security and increasing the cost of malicious behavior. Furthermore, it provides a scheme for calculating node votes, comprehensively evaluating voting performance. The number of votes a node possesses is not assigned equally to each account, but rather considers its total reward funds and the number of times it has participated in voting. This prevents malicious nodes from controlling the election by registering a large number of accounts; honest nodes can also obtain more voting rewards through active participation, preventing large accounts from monopolizing the voting process.

[0125] In summary, the blockchain consensus mechanism execution method and apparatus of this invention require participating representative nodes to provide a deposit during the election and work process. It utilizes a smart contract to load and execute a reward contract, providing a voting reward scheme for each node. This provides voting rewards for ordinary nodes participating in voting and accounting rewards for representative nodes' accounting activities, thereby increasing the enthusiasm of each node to participate in consensus operations. Simultaneously, it utilizes a smart contract to load and execute a penalty contract. In addition to delaying the distribution of voting and accounting rewards, it promptly removes abnormal representative nodes from the committee and deducts their deposits, voting rewards, and accounting rewards, increasing the cost of malicious behavior.

[0126] Furthermore, this invention calculates the number of votes held by each node based on the amount of reward funds held and the number of votes cast, which can prevent malicious nodes from controlling the election by registering a large number of accounts; it also ensures that honest nodes can obtain more voting rewards by actively participating in voting, and prevents large accounts from monopolizing the voting process.

[0127] Corresponding to the above method, the present invention also provides an apparatus / system including a computer device, the computer device including a processor and a memory, the memory storing computer instructions, the processor executing the computer instructions stored in the memory, and when the computer instructions are executed by the processor, the apparatus / system performs the steps of the method as described above.

[0128] This invention also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the aforementioned edge computing server deployment method. The computer-readable storage medium can be a tangible storage medium, such as random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, floppy disks, hard disks, removable storage disks, CD-ROMs, or any other form of storage medium known in the art.

[0129] Those skilled in the art will understand that the exemplary components, systems, and methods described in conjunction with the embodiments disclosed herein can be implemented in hardware, software, or a combination of both. Whether implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this invention. When implemented in hardware, it can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this invention are programs or code segments used to perform the desired tasks. The programs or code segments can be stored in a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried in a carrier wave.

[0130] It should be clarified that the present invention is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of the present invention.

[0131] In this invention, features described and / or illustrated for one embodiment may be used in the same or similar manner in one or more other embodiments, and / or combined with or in place of features of other embodiments.

[0132] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, various modifications and variations of the embodiments of the present invention are possible. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for executing a consensus mechanism of a blockchain, characterized in that, The method is based on a smart contract of a blockchain network, and in one cycle, the method comprises the following steps: Receiving a plurality of candidate nodes participating in the election as a stake to guarantee the bonus, receiving the votes of each node in the blockchain network for the candidate nodes, and recording the number of times each node participates in voting and the amount of bonus held by each node; Selecting a certain number of candidate nodes as representative nodes based on the voting contract, and releasing the stake of the remaining candidate nodes; After each representative node packs the transaction of the ordinary node in the agreed block sequence to form a block and verifies that there is no error, the block header is queried, and the number of times each representative node correctly blocks and the number of staked bonuses in the provided stake are recorded; Executing the reward contract, calculating the voting reward of each node according to the number of times each node participates in voting and the amount of bonus held by each node according to the first set of rules; calculating the accounting reward of each representative node according to the number of times each representative node correctly blocks and the number of staked bonuses in the provided stake according to the second set of rules, and delaying the voting reward and the accounting reward until the end of the cycle to issue; Before issuing the voting reward and the accounting reward, the punishment contract is executed, and when there is a representative node whose number of blocks is not reached a set value and / or implements malicious behavior, the representative node is kicked out and its corresponding stake, voting reward and accounting reward are deducted. 2.The method of claim 1, wherein, The bonus, the voting reward and the accounting reward use the bonus based on the Ethereum ERC20 standard to generate a cryptographic proof. 3.The method of claim 1, wherein, According to the first set of rules, the voting reward of each node is calculated according to the number of times each node participates in voting and the amount of bonus held by each node, including: Calculate the voting weight of the ith node, the calculation formula is: wherein, represents the voting weight of the i-th node, represents the reward level weight possessed by the i-th node, specifically, a plurality of weight levels are divided according to the number of rewards held by the node, and the more rewards held by the node, the greater the reward level weight corresponding to the corresponding weight level; is the number of times the i-th node participates in voting. Calculate the voting reward of the ith node in the xth voting round, the calculation formula is: wherein, represents the voting reward of the ith node in the xth voting round, represents the total value of the initial voting reward of the first period; represents the voting weight of the ith node. 4.The method of claim 1, wherein, In the method, when the smart contract records that there is an abnormal node voting, the total value of the voting reward of the next cycle is controlled to be reduced by a set proportion. 5.The method of claim 1, wherein, According to the second set of rules, the accounting reward of each representative node is calculated according to the number of times each representative node correctly blocks and the number of staked bonuses in the provided stake, including: Calculate the accounting reward weight of the ith representative node in the current cycle, the calculation formula is: wherein, represents the accounting reward weight of the i-th representative node in the current period, and is an adjustment coefficient, the i-th representative node corresponds to the number of staked reward funds in the margin, represents the correct block number of the i-th representative node packaged block, represents the time compensation increment; Calculate the accounting reward of the ith representative node, the calculation formula is: wherein, represents the accounting reward of the i-th representative node, represents the total value of the accounting reward of the current period. 6.The method of claim 5, wherein, the adjustment parameter and The initial value is 1 and the number of cycles is increased with a downshift. 7.The method of claim 5, wherein, The time compensation increment The number of cycles followed by an up-regulation in the range 0.02-0.

08. 8.The method of claim 1, wherein, When there is a representative node whose number of blocks is not reached a set value and / or implements malicious behavior, the representative node is kicked out and its corresponding stake, voting reward and accounting reward are deducted, including: When there is a representative node whose number of blocks is not reached a set value, and more than 1 / 2 of the representative nodes trigger the punishment contract in the verification process, the representative node is kicked out and its corresponding stake, voting reward and accounting reward are deducted; And / or, when there is a representative node that packs an error transaction or does not pack the transaction in sequence and uploads it to the chain, any representative node triggers the punishment contract in the verification process, the representative node is kicked out and its corresponding stake, voting reward and accounting reward are deducted. 9.A decentralized system of a blockchain network, comprising a blockchain network of a plurality of nodes, characterized in that, executing a smart contract on the blockchain network, the smart contract performing the steps of the method of any of claims 1 to 8.

10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The program which, when executed by the processor, implements the steps of the method of any of claims 1 to 8.