Consensus processing method and device in block chain system
By deploying smart contracts and punishment mechanisms in the blockchain system, the behavior of malicious nodes is automatically identified and handled, and the problem of malicious nodes destroying system stability is solved, and the robustness and stability of the system are improved.
Patent Information
- Application Number
- CN202510122471.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-24
- Publication Date
- 2025-04-25
AI Technical Summary
The existence of malicious nodes in the blockchain system may undermine the system's security and the activity of consensus protocols, causing system stability to be threatened.
Deploy smart contracts in the blockchain system to manage consensus nodes and introduce a punishment mechanism. By receiving consensus messages, determining malicious behaviors and generating punishment transactions, the punishment processing of malicious nodes will be automatically triggered.
It improves the cost of evil committed by consensus nodes, reduces malicious behavior, improves the robustness and stability of the blockchain system, and avoids the omission of punishment measures caused by manual intervention.
Smart Images

Figure CN119892341A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of this specification belong to the field of blockchain, and more particularly to a consensus processing method and device in a blockchain system. Background Art
[0002] In the blockchain system, different participants can establish a distributed blockchain network through deployed nodes. The decentralized distributed ledger constructed using the chain block structure can be stored on each node (or most nodes, such as consensus nodes) in the distributed blockchain network. Such a blockchain system needs to solve the problem of consistency and correctness of the ledger data on multiple decentralized nodes. Each node runs a blockchain program. Under certain fault tolerance requirements, the consensus protocol is run to ensure that all loyal nodes have the same transactions, thereby ensuring that all loyal nodes have consistent execution results for the same transaction, and the transactions and execution results are packaged to generate blocks.
[0003] In most current public chain implementations, in order to increase the enthusiasm of consensus nodes to participate in consensus, corresponding incentives are usually given to consensus nodes that have completed consensus. However, in actual applications, among the consensus nodes participating in consensus, there are very likely to be some malicious nodes (also known as Byzantine nodes), which may intentionally undermine the security of the blockchain system and the activity of the consensus protocol through some malicious behaviors during the consensus process. Since the malicious behaviors of Byzantine nodes are usually uncontrollable, these malicious behaviors in the consensus process may directly threaten the stability of the blockchain system. Summary of the invention
[0004] This specification proposes a consensus processing method in a blockchain system, which is applied to any consensus node participating in the consensus in the blockchain system; wherein a smart contract for managing the consensus nodes participating in the consensus is deployed on the blockchain; the method comprises:
[0005] Receive consensus messages sent by other consensus nodes during the consensus interaction process;
[0006] Determining whether the other consensus nodes have malicious behavior during the consensus interaction process based on the received consensus message;
[0007] If it is determined that any target consensus node among the other consensus nodes has malicious behavior during the consensus interaction process, the malicious node penalty logic contained in the smart contract is called to generate a penalty transaction for punishing the target consensus node, so that the consensus node responsible for generating blocks in the blockchain system will add the penalty transaction to the target block passed by consensus;
[0008] The penalty transaction included in the target block is executed to perform penalty processing on the target consensus node.
[0009] Optionally, the smart contract is a system smart contract deployed in the blockchain by an operator of a blockchain service platform corresponding to the blockchain system; accordingly, the penalty transaction is a system transaction that does not require consensus processing.
[0010] Optionally, if the malicious behavior does not cause the consensus of the block corresponding to the current round of consensus to fail, the target block is the block corresponding to the current round of consensus; if the malicious behavior causes the consensus of the block corresponding to the current round of consensus to fail, the target block is the block corresponding to the next round of consensus after the current round of consensus.
[0011] Optionally, the penalty transaction includes a consensus message related to the malicious behavior of the target consensus node; the consensus message carries the signature of the target consensus node;
[0012] Executing the penalty transaction contained in the target block and performing penalty processing on the target consensus node includes:
[0013] Verifying the signature of the consensus message in the penalty transaction included in the target block;
[0014] If the signature verification of the consensus message passes, it is confirmed based on the message content of the consensus message whether the target consensus node has the malicious behavior during the consensus interaction process; if so, the penalty transaction is executed to punish the target consensus node.
[0015] Optionally, generating a penalty transaction for punishing the target consensus node, including:
[0016] Generate a proof based on the message content of the consensus message related to the malicious behavior of the target consensus node; wherein the proof is used to indicate that the target consensus node has malicious behavior;
[0017] A penalty transaction is created for penalizing the target consensus node, and the generated proof is added to the penalty transaction.
[0018] Optionally, executing the penalty transaction included in the target block and performing penalty processing on the target consensus node includes:
[0019] Verifying the proof in the penalty transaction included in the target block;
[0020] If the verification of the proof passes, it is confirmed that the target consensus node has committed the malicious behavior during the consensus interaction, and the penalty transaction is further executed to punish the target consensus node.
[0021] Optionally, the target consensus node includes a consensus node in the blockchain system that has the authority to initiate a consensus proposal; the malicious behavior includes the behavior of simultaneously initiating multiple consensus proposals in one round of consensus.
[0022] Optionally, the target consensus node includes a consensus node in the blockchain system that does not have the authority to initiate a consensus proposal but has the authority to perform consensus voting on consensus proposals initiated by other consensus nodes; the malicious behavior includes submitting two different voting results for the same consensus proposal in one round of consensus.
[0023] Optionally, the smart contract maintains virtual resources transferred to the smart contract by each consensus node in the blockchain; wherein the virtual resources are used to obtain the right to participate in the consensus;
[0024] Punishment is performed on the target consensus node, including:
[0025] Based on a preset exception handling method related to the penalty processing, exception handling is performed on the virtual resources transferred by the target consensus node and maintained in the smart contract.
[0026] Optionally, the method further includes:
[0027] Revoke the target consensus node’s permission to continue participating in consensus.
[0028] Optionally, the exception handling method includes any one of the following handling methods:
[0029] Freezing the virtual resources;
[0030] Transferring the virtual resources to a designated blockchain account;
[0031] The virtual resources are distributed to other consensus nodes in this round of consensus that do not have malicious behavior.
[0032] This specification also proposes a consensus processing device in a blockchain system, which is applied to any consensus node participating in the consensus in the blockchain system; wherein a smart contract for managing the consensus nodes participating in the consensus is deployed on the blockchain; the device comprises:
[0033] The receiving module receives the consensus messages sent by other consensus nodes during the consensus interaction process;
[0034] A determination module, which determines whether the other consensus nodes have malicious behavior during the consensus interaction process based on the received consensus message;
[0035] A generation module, if it is determined that any target consensus node among the other consensus nodes has malicious behavior during the consensus interaction process, calls the malicious node penalty logic contained in the smart contract to generate a penalty transaction for punishing the target consensus node, so that the consensus node responsible for generating blocks in the blockchain system will add the penalty transaction to the target block passed by consensus;
[0036] An execution module executes the penalty transaction included in the target block and performs penalty processing on the target consensus node.
[0037] In the above embodiments, on the one hand, by introducing a penalty mechanism for consensus nodes with malicious behaviors in the consensus protocol, the consensus nodes detected with malicious behaviors can be punished during the operation of the consensus protocol, thereby increasing the cost of malicious behavior of the consensus nodes and reducing malicious behaviors during the operation of the consensus protocol, thereby improving the robustness and stability of the blockchain system.
[0038] On the other hand, in the process of running the consensus protocol, by calling the smart contract to generate a penalty transaction to punish the consensus node with malicious behavior, and by executing the penalty transaction, the consensus node with malicious behavior can be punished. It can be achieved that the generated transaction is automatically triggered to punish the consensus node with malicious behavior without human intervention, thereby avoiding the omission of punishment measures against malicious nodes caused by manual punishment of malicious nodes. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions of the embodiments of this specification, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0040] Figure 1 It is a flow chart of a consensus processing method in a blockchain system shown in an embodiment of this specification;
[0041] Figure 2 is a schematic structural diagram of an electronic device shown in an embodiment of this specification;
[0042] Figure 3 It is a block diagram of consensus processing in a blockchain system shown in one embodiment of this specification. DETAILED DESCRIPTION
[0043] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this specification.
[0044] The purpose of the specification is to propose a technical solution that introduces a penalty mechanism for consensus nodes with malicious behavior in the consensus protocol, so as to increase the cost of malicious behavior of consensus nodes and improve the robustness and stability of the blockchain system.
[0045] See also Figure 1 , Figure 1 This is a flowchart of a consensus processing method in a blockchain system shown in this specification, wherein the method is applied to any consensus node participating in the consensus in the blockchain system; wherein a smart contract for managing the consensus nodes participating in the consensus is deployed on the blockchain; and the method includes the following execution process:
[0046] Step 102: Receive consensus messages sent by other consensus nodes during the consensus interaction process;
[0047] The consensus nodes participating in the consensus in the blockchain system can perform consensus processing on the consensus proposals generated in each round of consensus by running the consensus protocol. The consensus protocol run by the consensus nodes participating in the consensus in the above blockchain system is not specifically limited in this specification.
[0048] For example, the current mainstream consensus protocols may include: POW (Proof of Work) protocol, POS (Proof of Stake) protocol, DPOS (Delegated Proof of Stake) protocol, PBFT (Practical Byzantine Fault Tolerance) protocol, HoneyBadgerBFT (HoneyBadger Byzantine Fault Tolerance) protocol, HotStuff protocol, and so on.
[0049] Among these consensus protocols, there is a type of consensus protocol driven by a master node. For this type of consensus protocol, there is usually only one master node in each round of consensus. In each round of consensus, the master node will uniformly initiate consensus proposals.
[0050] For example, the PBFT protocol and the HotStuff protocol are such master-node driven consensus protocols. In these consensus protocols, the master node can collect transactions published by other slave nodes, and build a consensus proposal (usually a transaction list) based on the collected transactions, and then publish the consensus proposal in a unified manner, and other slave nodes will perform consensus voting.
[0051] Among these consensus protocols, there is also a type of asynchronous consensus protocol. Unlike synchronous or semi-synchronous consensus protocols, asynchronous consensus protocols can run in asynchronous networks, and in asynchronous consensus protocols, the roles of all consensus nodes are equal, and there is no longer a distinction between master nodes and slave nodes. Therefore, this type of consensus protocol usually allows every consensus node participating in the consensus to initiate a consensus proposal.
[0052] For example, the HoneyBadgerBFT consensus protocol is an asynchronous consensus protocol that allows all consensus nodes participating in the consensus to initiate consensus proposals. In this consensus protocol, all consensus nodes participating in the consensus have the opportunity to initiate consensus proposals to the block corresponding to the block identifier by carrying a block identifier in the initiated consensus proposal. In addition, all consensus nodes participating in the consensus can not only initiate consensus proposals autonomously, but also vote on consensus proposals initiated by other consensus nodes.
[0053] In the process of running the consensus protocol, the consensus nodes in the blockchain system can complete the corresponding consensus processing process by exchanging consensus messages with each other. In addition to sending consensus messages to other consensus nodes, they can also receive consensus messages sent by other consensus nodes during the consensus interaction process.
[0054] Among them, the message types of consensus messages that consensus nodes need to interact with each other in the process of running the consensus protocol usually depend on the specific consensus protocol. The consensus message types supported by different consensus protocols usually have certain differences, which will not be introduced in detail in this manual.
[0055] For example, for the PBFT consensus protocol, in a round of consensus, the messages exchanged between the master node and the slave node usually include Pre-Prepare messages, Prepare messages, and Commit messages, etc. For the HotStuff protocol, in a round of consensus, the messages exchanged between the master node and the slave node usually include prepare messages, prepare-vote messages, pre-commit messages, pre-commit-vote messages, commit messages, commit-vote messages, etc.
[0056] Step 104, determining whether the other consensus nodes have malicious behavior during the consensus interaction process based on the received consensus message;
[0057] When running the consensus protocol, the consensus nodes in the blockchain system can determine whether other consensus nodes have engaged in malicious behavior during the consensus interaction based on the received consensus messages.
[0058] Among them, malicious behaviors that exist in the consensus nodes during the execution of the consensus protocol may generally include any form of behavior that can have a negative impact on the consensus process.
[0059] In one embodiment shown, for a consensus node in a blockchain system that has the authority to initiate consensus proposals, malicious behavior that exists during the execution of a consensus protocol may specifically include the behavior of simultaneously initiating multiple consensus proposals in one round of consensus.
[0060] For example, in one example, if the consensus protocol run by the consensus node in the blockchain system is the master node-driven consensus protocol mentioned above, since in this consensus protocol, only the master node has the authority to initiate consensus proposals, the consensus node with the authority to initiate consensus proposals can be the master node in the master node-driven consensus protocol mentioned above.
[0061] In another example, if the consensus protocol run by the consensus nodes in the blockchain system is the asynchronous consensus protocol mentioned above, since the consensus nodes in this consensus protocol can all independently initiate consensus proposals, the consensus nodes with the authority to initiate consensus proposals can be all the consensus nodes participating in the consensus in the asynchronous consensus protocol mentioned above.
[0062] In another illustrated embodiment, for a consensus node in the blockchain system that does not have the authority to initiate a consensus proposal but has the authority to perform consensus voting on consensus proposals initiated by other consensus nodes, malicious behavior that exists during the execution of the consensus protocol may specifically include submitting two different voting results for the same consensus proposal in one round of consensus.
[0063] For example, in one example, if the consensus protocol run by the consensus nodes in the blockchain system is the master node-driven consensus protocol mentioned above, since in this consensus protocol, only the master node has the authority to initiate consensus proposals, the slave nodes can only reach consensus on the consensus proposals initiated by the master node. Therefore, the consensus nodes that do not have the authority to initiate consensus proposals but have the ability to vote on consensus proposals initiated by other consensus nodes can specifically be slave nodes in the master node-driven consensus protocol.
[0064] In another example, if the consensus protocol run by the consensus nodes in the blockchain system is the asynchronous consensus protocol mentioned above, since the consensus nodes in this consensus protocol can not only independently initiate consensus proposals, but also perform consensus votes on consensus proposals initiated by other consensus nodes, the consensus nodes that do not have the authority to initiate consensus proposals but have the authority to perform consensus votes on consensus proposals initiated by other consensus nodes can specifically be all consensus nodes participating in the consensus in the asynchronous consensus protocol.
[0065] It should be emphasized that in actual applications, the malicious behaviors of consensus nodes in the process of running the consensus protocol may include, in addition to the "behavior of simultaneously launching multiple consensus proposals in one round of consensus" and "the behavior of submitting two different voting results for the same consensus proposal" mentioned in the above examples, other types of malicious behaviors are also included; for example, the behavior of tampering with the message content of the consensus message, the behavior of delaying the sending of the consensus message, the behavior of refusing to send the consensus message, the behavior of forging the consensus message, the behavior of delaying the confirmation of the received consensus message, the behavior of malicious voting based on the consensus message, etc., which will not be listed one by one in this manual.
[0066] The specific way in which the consensus nodes in the blockchain system determine whether other consensus nodes have engaged in malicious behavior during the consensus interaction process based on the received consensus messages may usually be related to the specific type of malicious behavior. For different malicious behaviors, there may also be certain differences in the specific way in which the consensus nodes determine whether such malicious behavior exists based on the received consensus messages.
[0067] For example, taking the malicious behavior of initiating multiple consensus proposals at the same time in a round of consensus as an example, after receiving the consensus message sent by a certain target consensus node in a round of consensus, the consensus node in the blockchain system can parse the message content of the consensus message to obtain the consensus proposal initiated by the target consensus node carried in the consensus message. Then, by comparing whether the consensus proposals carried in the multiple consensus messages sent by the target consensus node are the same, it can be confirmed whether the target consensus node has initiated multiple consensus proposals at the same time in this round of consensus; if it is confirmed that the target consensus node has initiated multiple consensus proposals at the same time in this round of consensus, it indicates that the target consensus node has committed the malicious behavior in this round of consensus.
[0068] For another example, taking the behavior of submitting two different voting results for the same consensus proposal in a round of consensus as an example, after receiving a consensus message sent by a target consensus node in a round of consensus, the consensus node in the blockchain system can parse the message content of the consensus message to obtain the consensus voting result submitted by the target consensus node for a certain consensus proposal carried in the consensus message. Then, by comparing whether there is a conflict in the consensus voting results for the same consensus proposal carried in multiple consensus messages sent by the target consensus node, it can be confirmed whether the target consensus node has submitted two different voting results for the same consensus proposal; if it is confirmed that the voting results submitted by the target consensus node for the same consensus proposal in this round of consensus conflict with each other, that is, at least two completely different voting results are submitted, it indicates that the target consensus node has committed the malicious behavior in this round of consensus.
[0069] Step 106, if it is determined that any target consensus node among the other consensus nodes has malicious behavior during the consensus interaction process, the malicious node penalty logic contained in the smart contract is called to generate a penalty transaction for punishing the target consensus node, so that the consensus node responsible for generating blocks in the blockchain system adds the penalty transaction to the target block passed by consensus;
[0070] In order to facilitate the management of consensus nodes participating in the consensus, a smart contract for managing consensus nodes participating in the consensus can also be deployed on the blockchain. The contract code of the smart contract can specifically include the contract code related to the management logic for daily management of consensus nodes participating in the consensus that has been developed in advance. In addition, it can also include the contract code related to the malicious node penalty logic for punishing consensus nodes with malicious behavior.
[0071] Among them, the malicious node penalty logic can specifically be the execution logic of generating a penalty transaction to punish the consensus node with malicious behavior.
[0072] In this case, if the consensus node in the blockchain system determines, based on the received consensus message, that any target consensus node among other consensus nodes has engaged in malicious behavior during the consensus interaction process, it can further call the malicious node penalty logic contained in the above-mentioned smart contract to generate a penalty transaction for punishing the target consensus node, and the consensus node responsible for generating blocks in the blockchain system will add the penalty transaction generated by the smart contract to the target block passed by consensus.
[0073] For example, in one embodiment shown, a smart contract can save the generated penalty transaction to the contract call result, where the contract call result is usually in the form of a generated smart contract event, and the consensus node responsible for generating blocks in the blockchain system can discover and obtain the contract call result contained in the smart contract event by listening to the smart contract event generated by the smart contract, and then read the penalty transaction generated by the smart contract from the contract call result, and then package the penalty transaction into the target block passed by consensus.
[0074] In one embodiment shown, the above-mentioned smart contract can be a system smart contract deployed on the blockchain by the operator of the blockchain service platform corresponding to the blockchain system. It should be noted that for ordinary smart contracts deployed on the blockchain, the execution logic of the contract code contained therein can usually be some user-level service logic, and unlike ordinary smart contracts, the execution logic of the contract code contained in the system smart contract can usually be some execution logic related to some system-level call behaviors on the blockchain service platform corresponding to the blockchain system. In this case, the penalty transaction generated by calling the malicious node penalty logic contained in the system smart contract can be a system transaction that does not require consensus processing.
[0075] For example, conventional transactions in blockchain usually contain information about the sender of the transaction, but since system transactions usually describe the system call behavior of the blockchain service platform corresponding to the blockchain system, system transactions may not contain information about the sender of the transaction. In other words, compared to ordinary transactions, system transactions are special transactions that do not require consensus processing and may not contain information about the sender of the transaction.
[0076] It should be noted that the consensus nodes responsible for generating blocks in the blockchain system usually have different regulations in different consensus protocols.
[0077] For example, if the consensus protocol run by the consensus nodes in the blockchain system is the above master node driven consensus protocol, then in each round of consensus, the master node will be responsible for generating blocks. If the consensus protocol run by the consensus nodes in the blockchain system is the above asynchronous consensus protocol, then in each round of consensus, a consensus node responsible for generating blocks can be pre-designated from all consensus nodes participating in the consensus, or all consensus nodes participating in the consensus can take turns to generate blocks according to certain rules.
[0078] When the consensus node responsible for generating blocks in the blockchain system adds the above-mentioned penalty transaction to the target block passed by consensus, the specific location of the penalty transaction in the target block is not specifically limited in this specification.
[0079] For example, in one example, the penalty transaction can specifically be the last transaction included in the target block. In this way, other transactions in the target block can be executed first, thereby ensuring that the penalty transaction is executed after other transactions in the target block are successfully executed, and punishing the target consensus node with malicious behavior.
[0080] Among them, the above-mentioned target block for adding penalty transactions may be the block corresponding to the current round of consensus or the block corresponding to the next round of consensus after the current round of consensus in different situations.
[0081] In one embodiment shown, after a consensus node in a blockchain system determines, based on a received consensus message, that any target consensus node among other consensus nodes has engaged in malicious behavior during the consensus interaction process, if the malicious behavior does not cause a consensus failure in a block corresponding to this round of consensus at this time, then the target block may specifically be a block corresponding to this round of consensus.
[0082] For example, in one example, the malicious behavior mentioned above can be specifically the "behavior of submitting two different voting results for the same consensus proposal" mentioned above. Since a small number of consensus nodes submit two different voting results for the same consensus proposal, it usually does not lead to a consensus failure in a round of consensus, and the block corresponding to this round of consensus can usually still pass the consensus normally; therefore, in this case, the target block mentioned above can specifically be the block corresponding to this round of consensus. The consensus node responsible for generating blocks in this round of consensus can add the penalty transaction generated by calling the above smart contract to the block corresponding to this round of consensus after the block corresponding to this round of consensus completes the consensus.
[0083] In another embodiment shown, after the consensus node in the blockchain system determines, based on the received consensus message, that any target consensus node among other consensus nodes has engaged in malicious behavior during the consensus interaction process, if the malicious behavior does not cause a consensus failure in the block corresponding to this round of consensus at this time, then the target block may specifically be the block corresponding to this round of consensus.
[0084] For example, in one example, the malicious behavior mentioned above can be specifically the "behavior of initiating multiple consensus proposals simultaneously in one round of consensus" mentioned above. On the one hand, in the consensus protocol driven by the master node, if the master node acts as a malicious node and "initiates multiple consensus proposals simultaneously in one round of consensus" in the process of consensus interaction, it will usually trigger the switching of the master node, which will lead to the failure of consensus in this round of consensus; therefore, when the consensus protocol run by the consensus node in the blockchain system is a consensus protocol driven by the master node, the target block mentioned above can be specifically the block corresponding to the next round of consensus led by the new master node after the master node switching is triggered. After the block corresponding to the next round of consensus led by the new master node completes the consensus, the penalty transaction generated by calling the above smart contract can be added to the block corresponding to the next round of consensus.
[0085] On the other hand, since all consensus nodes can initiate consensus proposals in the asynchronous consensus protocol, if only some consensus nodes initiate multiple consensus proposals in a round of consensus during the consensus interaction, it may not lead to consensus failure in this round of consensus; therefore, when the consensus protocol run by the consensus nodes in the blockchain system is an asynchronous consensus protocol, the above target block can specifically be the block corresponding to this round of consensus. The consensus node responsible for generating blocks in this round of consensus can add the penalty transaction generated by calling the above smart contract to the block corresponding to this round of consensus after the consensus is completed on the block corresponding to this round of consensus.
[0086] In this way, the generated penalty transaction can be packaged into the consensus-passed block as quickly as possible.
[0087] Step 108: execute the penalty transaction contained in the target block and perform penalty processing on the target consensus node.
[0088] After the above-mentioned penalty transaction is added to the target block passed by the consensus responsible for generating the block, during the execution phase of the target block, each consensus node can punish the target consensus node that has malicious behavior during the consensus interaction process by executing the penalty transaction contained in the target block.
[0089] Among them, it should be noted that the transaction content included in the above-mentioned penalty transaction can usually be some information related to the malicious behavior of the target consensus node. In the process of executing the penalty transaction, each consensus node can verify the authenticity of the malicious behavior of the target consensus node based on the transaction content included in the penalty transaction, and then, if it is confirmed that the target consensus node does have malicious behavior during the consensus interaction process, it can continue to execute the penalty transaction and punish the target consensus node.
[0090] For example, in one embodiment shown, the penalty transaction may specifically include consensus messages related to the malicious behavior of the target consensus node; wherein, these consensus messages may specifically carry the signature of the target consensus node. In this case, in the process of executing the penalty transaction, each consensus node may first verify the signature of the consensus message included in the penalty transaction; if the signature verification of the consensus message passes, it may continue to confirm whether the target consensus node has malicious behavior during the consensus interaction based on the message content of the consensus message; if it is confirmed that the target consensus node does have malicious behavior, the penalty transaction may be further executed to punish the target consensus node.
[0091] In another embodiment shown, when the malicious node penalty logic contained in the above-mentioned smart contract is called to generate the penalty transaction, consensus messages related to the malicious behavior of the target consensus node can be obtained, and a proof can be generated based on the message content of these consensus messages; wherein, the proof is used to indicate that the target consensus node has malicious behavior; then, a penalty transaction for punishing the target consensus node can be created, and the generated proof can be added to the penalty transaction.
[0092] In this case, each consensus node can verify the proof contained in the penalty transaction during the execution of the penalty transaction; if the verification of the proof is successful, it can be confirmed that the target consensus node did indeed engage in the malicious behavior during the consensus interaction process, and the penalty transaction can be further executed to punish the target consensus node.
[0093] The specific form of the proof generated based on the message content of these consensus messages is not specifically limited in this specification. In practical applications, any form of verifiable credentials can be used as the proof.
[0094] For example, in one example, the proof may specifically be an aggregate signature generated using aggregate signature technology based on signatures in the message content of the consensus messages obtained.
[0095] When each consensus node in the blockchain system executes the above-mentioned penalty transaction and punishes the target consensus node that has malicious behavior during the consensus interaction, the specific penalty processing method adopted is not specifically limited in this specification. In actual application, it can be flexibly customized based on specific needs.
[0096] In one embodiment shown, the blockchain system can specifically adopt a mechanism of accessing the blockchain system by pledging a certain amount of virtual resources to the operator of the blockchain system. Under this mechanism, each consensus node in the blockchain can obtain the right to participate in the consensus by pledging a certain amount of virtual resources to the operator of the blockchain system. The virtual resources pledged by each consensus node in the blockchain to the operator of the blockchain system can be transferred to the above-mentioned smart contract and maintained uniformly by the smart contract.
[0097] For example, taking the above-mentioned smart contract as a system smart contract deployed by the operator of the blockchain system on the blockchain to manage consensus nodes, each consensus node in the blockchain can transfer the pledged virtual resources to the system smart contract through the resource transfer function between blockchain accounts supported by the blockchain itself, and the system smart contract will be used for unified maintenance. Then, in the actual operation process, the operator of the blockchain system can confirm whether to grant the authority to participate in the consensus to each consensus node based on the number of virtual resources pledged by each consensus node by calling the management logic contained in the system smart contract.
[0098] In this scenario, when each consensus node in the blockchain system executes the above-mentioned penalty transaction and punishes the target consensus node that has malicious behavior during the consensus interaction, it can specifically perform exception handling on the virtual resources transferred by the target consensus node and maintained in the smart contract based on the preset exception handling method related to the penalty handling.
[0099] Among them, the above-mentioned exception handling method can be flexibly configured based on specific needs in actual applications and is not particularly limited in this specification.
[0100] For example, in one example, the above exception handling method may specifically include any one of the following handling methods:
[0101] Freeze virtual resources; transfer virtual resources to a designated blockchain account; distribute virtual resources to other consensus nodes in this round of consensus that do not have malicious behavior.
[0102] Of course, in actual applications, the punishment measures used to punish the target consensus node with malicious behavior can include the above-mentioned means of abnormal handling of the virtual resources pledged by the target consensus node, and other punishment measures can be further introduced on this basis.
[0103] For example, in one embodiment shown, when each consensus node in the blockchain system executes the above-mentioned penalty transaction and punishes the target consensus node that has engaged in malicious behavior during the consensus interaction, it can also further revoke the target consensus node's authority to continue to participate in the consensus as a means of punishment based on abnormal handling of the virtual resources pledged by the target consensus node.
[0104] In the above technical solution, on the one hand, by introducing a penalty mechanism for consensus nodes with malicious behaviors in the consensus protocol, the consensus nodes that are detected to have malicious behaviors can be punished during the operation of the consensus protocol, thereby increasing the cost of malicious behavior of the consensus nodes and reducing malicious behaviors during the operation of the consensus protocol, thereby improving the robustness and stability of the blockchain system.
[0105] On the other hand, in the process of running the consensus protocol, by calling the smart contract to generate a penalty transaction to punish the consensus node with malicious behavior, and by executing the penalty transaction, the consensus node with malicious behavior can be punished. It can be achieved that the generated transaction is automatically triggered to punish the consensus node with malicious behavior without human intervention, thereby avoiding the omission of punishment measures against malicious nodes caused by manual punishment of malicious nodes.
[0106] For example, according to the process mentioned above, as soon as this round of consensus is completed, a penalty transaction can be added to the consensus-passed block, and then during the execution phase of the block, the penalty processing for malicious nodes can be automatically triggered without human intervention.
[0107] Corresponding to the embodiments of the aforementioned method, this specification also provides embodiments of an apparatus, an electronic device, and a storage medium.
[0108] Figure 2 is a schematic structural diagram of an electronic device provided by an exemplary embodiment. Figure 2At the hardware level, the device includes a processor 202, an internal bus 204, a network interface 206, a memory 208, and a non-volatile memory 210, and may also include other required hardware. One or more embodiments of this specification may be implemented based on software, such as the processor 202 reading the corresponding computer program from the non-volatile memory 210 into the memory 208 and then running it. Of course, in addition to the software implementation, one or more embodiments of this specification do not exclude other implementations, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but may also be hardware or logic devices.
[0109] like Figure 3 As shown, Figure 3 This is a block diagram of a consensus process in a blockchain system according to an exemplary embodiment of the present specification. The device can be applied to Figure 2 In the electronic device shown in the figure, the technical solution of this specification is implemented. The device is applied to any consensus node participating in the consensus in the blockchain system; wherein a smart contract for managing the consensus nodes participating in the consensus is deployed on the blockchain; the device 300 includes:
[0110] Receiving module 301, receiving consensus messages sent by other consensus nodes during the consensus interaction process;
[0111] Determination module 302, determining whether the other consensus nodes have malicious behavior during the consensus interaction process based on the received consensus message;
[0112] The generation module 303, if it is determined that any target consensus node among the other consensus nodes has malicious behavior during the consensus interaction process, calls the malicious node penalty logic contained in the smart contract to generate a penalty transaction for punishing the target consensus node, so that the consensus node responsible for generating blocks in the blockchain system adds the penalty transaction to the target block passed by consensus;
[0113] The execution module 304 executes the penalty transaction included in the target block and performs penalty processing on the target consensus node.
[0114] Accordingly, the present specification also provides an electronic device, which includes a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to implement the steps in all the method flows described above.
[0115] Accordingly, the present specification also provides a computer-readable storage medium on which executable computer program instructions are stored; wherein, when the instructions are executed by a processor, the steps in all the method flows described above are implemented.
[0116] Accordingly, the present specification also provides a computer program product having executable computer program instructions stored thereon; wherein, when the computer program instructions are executed by a processor, the steps in all the method flows described above are implemented.
[0117] In the 1990s, improvements to a technology could be clearly distinguished as hardware improvements (for example, improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the method flow). However, with the development of technology, many improvements to the method flow today can be regarded as direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask a chip manufacturer to design and produce a dedicated integrated circuit chip. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.
[0118] The controller can be implemented in any appropriate manner, for example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code manner, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be regarded as structures within the hardware component. Or even, the devices for implementing various functions can be regarded as both software modules for implementing the method and structures within the hardware component.
[0119] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a server system. Of course, the present application does not exclude that with the development of computer technology in the future, the computer that implements the functions of the above embodiments may be, for example, a personal computer, a laptop computer, a vehicle-mounted human-computer interaction device, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0120] Although one or more embodiments of the present specification provide method operation steps as described in the embodiments or flow charts, more or less operation steps may be included based on conventional or non-creative means. The order of steps listed in the embodiments is only one way of executing the order of many steps, and does not represent the only execution order. When the device or terminal product in practice is executed, it can be executed in sequence or in parallel according to the method shown in the embodiments or the drawings (for example, a parallel processor or a multi-threaded processing environment, or even a distributed data processing environment). The term "include", "include" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, product or equipment including a series of elements includes not only those elements, but also includes other elements that are not explicitly listed, or also includes elements inherent to such a process, method, product or equipment. In the absence of more restrictions, it is not excluded that there are other identical or equivalent elements in the process, method, product or equipment including the elements. For example, if the words first, second, etc. are used to represent the name, they do not represent any specific order.
[0121] For the convenience of description, the above devices are described in various modules according to their functions. Of course, when implementing one or more of the present specification, the functions of each module can be implemented in the same or more software and / or hardware, or the module implementing the same function can be implemented by a combination of multiple sub-modules or sub-units, etc. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0122] The present invention is described with reference to flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0123] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0124] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0125] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0126] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0127] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage, graphene storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0128] It should be understood by those skilled in the art that one or more embodiments of the present specification may be provided as a method, system or computer program product. Therefore, one or more embodiments of the present specification may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, one or more embodiments of the present specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0129] One or more embodiments of this specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. One or more embodiments of this specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0130] Each embodiment in this specification is described in a progressive manner, and the same and similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. In the description of this specification, the description of the reference terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of this specification. In this specification, the schematic representation of the above terms does not necessarily target the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art can combine and combine the different embodiments or examples described in this specification and the features of different embodiments or examples without contradiction.
[0131] The above description is only an example of one or more embodiments of this specification and is not intended to limit one or more embodiments of this specification. For those skilled in the art, one or more embodiments of this specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this specification shall be included in the scope of the claims.
Claims
1. A consensus processing method in a blockchain system, the method being applied to any consensus node participating in the consensus in the blockchain system; wherein: A smart contract for managing consensus nodes participating in consensus is deployed on the blockchain; the method includes: Receive consensus messages sent by other consensus nodes during the consensus interaction process; Determining whether the other consensus nodes have malicious behavior during the consensus interaction process based on the received consensus message; If it is determined that any target consensus node among the other consensus nodes has malicious behavior during the consensus interaction process, the malicious node penalty logic contained in the smart contract is called to generate a penalty transaction for punishing the target consensus node, so that the consensus node responsible for generating blocks in the blockchain system will add the penalty transaction to the target block passed by consensus; The penalty transaction included in the target block is executed to perform penalty processing on the target consensus node.
2. According to the method as claimed in claim 1, the smart contract is a system smart contract deployed in the blockchain by the operator of the blockchain service platform corresponding to the blockchain system; accordingly, the penalty transaction is a system transaction that does not require consensus processing.
3. According to the method as claimed in claim 1, if the malicious behavior does not cause the consensus of the block corresponding to the current round of consensus to fail, the target block is the block corresponding to the current round of consensus; if the malicious behavior causes the consensus of the block corresponding to the current round of consensus to fail, the target block is the block corresponding to the next round of consensus after the current round of consensus.
4. The method of claim 2, wherein the penalty transaction includes a consensus message related to the malicious behavior of the target consensus node; The consensus message carries the signature of the target consensus node; Executing the penalty transaction contained in the target block and performing penalty processing on the target consensus node includes: Verifying the signature of the consensus message in the penalty transaction included in the target block; If the signature verification of the consensus message passes, it is confirmed based on the message content of the consensus message whether the target consensus node has the malicious behavior during the consensus interaction process; if so, the penalty transaction is executed to punish the target consensus node.
5. The method according to claim 2, generating a penalty transaction for punishing the target consensus node, comprising: Generate a proof based on the message content of the consensus message related to the malicious behavior of the target consensus node; wherein the proof is used to indicate that the target consensus node has malicious behavior; A penalty transaction is created for penalizing the target consensus node, and the generated proof is added to the penalty transaction.
6. The method according to claim 5, executing the penalty transaction contained in the target block and performing penalty processing on the target consensus node, comprising: Verifying the proof in the penalty transaction included in the target block; If the verification of the proof passes, it is confirmed that the target consensus node has committed the malicious behavior during the consensus interaction, and the penalty transaction is further executed to punish the target consensus node.
7. In the method as claimed in claim 1, the target consensus node includes a consensus node in the blockchain system that has the authority to initiate a consensus proposal; and the malicious behavior includes the behavior of simultaneously initiating multiple consensus proposals in one round of consensus.
8. In the method as claimed in claim 1, the target consensus node includes a consensus node in the blockchain system that does not have the authority to initiate a consensus proposal but has the authority to perform consensus voting on consensus proposals initiated by other consensus nodes; the malicious behavior includes submitting two different voting results for the same consensus proposal in one round of consensus.
9. The method of claim 1, wherein the smart contract maintains virtual resources transferred to the smart contract by each consensus node in the blockchain; wherein: The virtual resources are used to obtain the authority to participate in the consensus; Punishment is performed on the target consensus node, including: Based on a preset exception handling method related to the penalty processing, exception handling is performed on the virtual resources transferred by the target consensus node and maintained in the smart contract.
10. The method of claim 9, further comprising: Revoke the target consensus node’s permission to continue participating in consensus.
11. The method according to claim 9, wherein the abnormality handling method comprises any one of the following handling methods: Freezing the virtual resources; Transferring the virtual resources to a designated blockchain account; The virtual resources are distributed to other consensus nodes in this round of consensus that do not have malicious behavior.
12. A consensus processing device in a blockchain system, the device being applied to any consensus node participating in the consensus in the blockchain system; wherein: A smart contract for managing consensus nodes participating in consensus is deployed on the blockchain; the device includes: The receiving module receives the consensus messages sent by other consensus nodes during the consensus interaction process; A determination module, which determines whether the other consensus nodes have malicious behavior during the consensus interaction process based on the received consensus message; A generation module, if it is determined that any target consensus node among the other consensus nodes has malicious behavior during the consensus interaction process, calls the malicious node penalty logic contained in the smart contract to generate a penalty transaction for punishing the target consensus node, so that the consensus node responsible for generating blocks in the blockchain system will add the penalty transaction to the target block passed by consensus; An execution module executes the penalty transaction included in the target block and performs penalty processing on the target consensus node.
13. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 11 are implemented.
14. A computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the method according to any one of claims 1 to 11.
15. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.