Processing method, device and electronic device for consensus mechanism in blockchain

By storing multiple consensus mechanisms in the blockchain node device and dynamically updating the default mechanism, the problem of the blockchain network being unable to replace the consensus mechanism is solved, and the flexibility and ecological expansion of the blockchain network are achieved.

CN111861469BActive Publication Date: 2024-10-29BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202010735354.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-07-27
Publication Date
2024-10-29
Estimated Expiration
2040-07-27

AI Technical Summary

Technical Problem

The existing blockchain network cannot replace and modify the consensus mechanism after startup, making it difficult to meet changes in business needs and the expansion of the blockchain ecosystem.

Method used

Multiple consensus mechanisms are stored in the blockchain node device, and the default consensus mechanism is updated by receiving consensus mechanism change instructions or notifications to achieve dynamic replacement and compatibility of the consensus mechanism, allowing the node device to select and replace different consensus mechanisms according to business needs.

Benefits of technology

Completing the replacement of the consensus mechanism without restarting the blockchain network improves the flexibility of the blockchain network, allowing users to choose and replace different consensus mechanisms according to business needs, which is conducive to the further development of the blockchain ecosystem.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111861469B_ABST
    Figure CN111861469B_ABST
Patent Text Reader

Abstract

The present application provides a method, device and electronic device for processing a consensus mechanism in a blockchain, the method comprising: if the current node device in the blockchain receives a consensus mechanism change instruction, the default consensus mechanism in the current node device is updated to the target consensus mechanism indicated by the consensus mechanism change instruction; and the designated device in the blockchain is notified to update the default consensus mechanism in the designated device to the target consensus mechanism. In this method, multiple consensus mechanisms are made compatible in the blockchain, so that the node devices in the blockchain can change the default consensus mechanism used to the target consensus mechanism according to the consensus mechanism change instruction and notification. Therefore, this method completes the replacement operation of the consensus mechanism without restarting the blockchain network, improves the flexibility of the consensus mechanism of the blockchain network, so that users can choose and replace different consensus mechanisms according to business needs, which is conducive to the further development of the blockchain ecology.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of blockchain technology, and in particular to a method, device and electronic device for processing a consensus mechanism in a blockchain. Background Art

[0002] The consensus mechanism refers to the process by which nodes participating in the consensus in the blockchain network reach a consistent state. This process means that multiple nodes reach a consensus on the order and legitimacy of a batch of transactions and their updates to the ledger status.

[0003] In the related art, a blockchain network (e.g., Hyperledger Fabric network) can provide multiple consensus mechanisms. Before the blockchain network is started, the internal configuration needs to be completed, and the internal configuration can only include one consensus mechanism selected by the user; after the network is successfully started, the nodes in the blockchain network complete the consensus sorting service for the business submitted on the blockchain network based on the consensus mechanism. This method cannot replace and modify the consensus mechanism after the network is successfully started, which makes it difficult to meet and adapt to the increasing and changing business needs of the blockchain network, and is not conducive to the expansion of the blockchain ecosystem. Summary of the invention

[0004] The purpose of this application is to provide a method, device and electronic device for processing the consensus mechanism in a blockchain to meet and adapt to the increasing and changing business needs of the blockchain network and to help expand the blockchain ecosystem.

[0005] In a first aspect, an embodiment of the present application provides a method for processing a consensus mechanism in a blockchain, the method being applied to a node device in a blockchain, wherein a plurality of consensus mechanisms and a default consensus mechanism in an activated state are stored in the node device; the default consensus mechanism is used to: provide consensus sorting services to services received by the node device; the method comprising: if a consensus mechanism change instruction is received, updating the default consensus mechanism in the current node device to a target consensus mechanism indicated by the consensus mechanism change instruction; notifying a designated device in the blockchain to update the default consensus mechanism in the designated device to a target consensus mechanism; wherein the designated device comprises: a node device in the blockchain other than the current node device for providing consensus sorting services.

[0006] In an optional implementation, the above-mentioned blockchain is a designated network; the multiple consensus mechanisms include: an inherent consensus mechanism of the designated network, and / or a user-defined consensus mechanism.

[0007] In an optional embodiment, if a consensus mechanism change instruction is received, before the step of updating the default consensus mechanism in the current node device to the target consensus mechanism indicated by the consensus mechanism change instruction, the method also includes: performing initialization operations on multiple consensus mechanisms to obtain a consensus instance of each consensus mechanism; wherein the consensus instance is used to perform a consensus sorting operation.

[0008] In an optional implementation, the above-mentioned step of initializing multiple consensus mechanisms to obtain a consensus instance of each consensus mechanism includes: for each consensus mechanism among the multiple consensus mechanisms, performing the following operations: compiling the code of the current consensus mechanism into an executable file; setting initial values ​​for parameters and / or conditions in the executable file to obtain a consensus instance of the current consensus mechanism.

[0009] In an optional embodiment, after the above-mentioned step of initializing multiple consensus mechanisms to obtain a consensus instance of each consensus mechanism, the method further includes: uploading the consensus instance of each consensus mechanism or the consensus instance of the default consensus mechanism to the ledger manager of the blockchain, so as to call the consensus instance of the default consensus mechanism from the ledger manager through the node device, and perform a consensus sorting operation on the business received by the node device.

[0010] In an optional implementation, the ledger manager of the above-mentioned blockchain stores consensus instances of multiple consensus mechanisms, and the consensus instances are used to perform consensus sorting operations; before the above-mentioned step of updating the default consensus mechanism in the current node device to the target consensus mechanism indicated by the consensus mechanism change instruction, the method also includes: querying whether the ledger manager contains the consensus instance of the target consensus mechanism; if the consensus instance of the target consensus mechanism is not contained, uploading the consensus instance of the target consensus mechanism to the ledger manager.

[0011] In an optional implementation, the ledger manager of the above-mentioned blockchain stores consensus instances of multiple consensus mechanisms, and the consensus instances are used to perform consensus sorting operations; after the above-mentioned step of updating the default consensus mechanism in the current node device to the target consensus mechanism indicated by the consensus mechanism change instruction, the method also includes: querying whether the ledger manager contains the consensus instance of the target consensus mechanism; if the consensus instance of the target consensus mechanism is contained, calling the consensus instance of the target consensus mechanism from the ledger manager to adopt the consensus instance of the target consensus mechanism to perform consensus sorting operations on the services received by the node device.

[0012] In a second aspect, an embodiment of the present application provides a method for processing a consensus mechanism in a blockchain, the method being applied to a node device in a blockchain, the node device comprising a default consensus mechanism in an activated state; the default consensus mechanism being used to: provide consensus sorting services to services received by the node device; the method comprising: if a notification of a change in the consensus mechanism is received, updating the default consensus mechanism in the current node device to a target consensus mechanism indicated by the notification; wherein the notification is sent by a node device in the blockchain, other than the current node device, for providing consensus sorting services.

[0013] In an optional implementation, if a notification of changing the consensus mechanism is received, the step of updating the default consensus mechanism in the current node device to the target consensus mechanism indicated by the notification includes: endorsing the notification to obtain an endorsement result; wherein the endorsement operation is used to verify whether the node device sending the notification is the designated node device; if the endorsement result indicates that the node device sending the notification is the designated node device, updating the default consensus mechanism in the current node device to the target consensus mechanism.

[0014] In an optional implementation, the ledger manager of the above-mentioned blockchain stores consensus instances of multiple consensus mechanisms, which are used to perform consensus sorting operations; if the endorsement result indicates that the node device sending the notification is a designated node device, the step of updating the default consensus mechanism in the current node device to the target consensus mechanism includes: querying whether the ledger manager contains a consensus instance of the target consensus mechanism; if the ledger manager does not contain a consensus instance of the target consensus mechanism, sending a consensus instance upload instruction to the designated node device so that the designated node device uploads the consensus instance of the target consensus mechanism to the ledger manager; if the ledger manager contains a consensus instance of the target consensus mechanism, calling the consensus instance of the target consensus mechanism from the ledger manager to adopt the consensus instance of the target consensus mechanism to perform a consensus sorting operation on the business received by the node device.

[0015] In a third aspect, an embodiment of the present application provides a device for processing a consensus mechanism in a blockchain, wherein the device is arranged in a node device in the blockchain, wherein a plurality of consensus mechanisms and a default consensus mechanism in an activated state are stored in the node device; the default consensus mechanism is used to provide consensus sorting services to services received by the node device; the device comprises: a change instruction receiving module, which is used to update the default consensus mechanism in the current node device to the target consensus mechanism indicated by the consensus mechanism change instruction if a consensus mechanism change instruction is received; a mechanism change notification module, which is used to notify a designated device in the blockchain to update the default consensus mechanism in the designated device to the target consensus mechanism; wherein the designated device comprises: a node device in the blockchain, other than the current node device, for providing consensus sorting services.

[0016] In a fourth aspect, an embodiment of the present application provides a device for processing a consensus mechanism in a blockchain, wherein the device is arranged in a node device in the blockchain, and the node device includes a default consensus mechanism in an activated state; the default consensus mechanism is used to: provide consensus sorting services to the services received by the node device; the device includes: a mechanism change module, which is used to update the default consensus mechanism in the current node device to the target consensus mechanism indicated by the notification if a notification of changing the consensus mechanism is received; wherein the notification is sent by a node device in the blockchain other than the current node device that is used to provide consensus sorting services.

[0017] In a fifth aspect, an embodiment of the present application provides an electronic device, including a processor and a memory, wherein the memory stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions to implement the processing method of the consensus mechanism in the above-mentioned blockchain.

[0018] In a sixth aspect, an embodiment of the present application provides a machine-readable storage medium, which stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the processing method of the consensus mechanism in the above-mentioned blockchain.

[0019] The embodiments of the present application bring the following beneficial effects:

[0020] The embodiment of the present application provides a method, device and electronic device for processing a consensus mechanism in a blockchain. The method is applied to a node device in a blockchain, in which a plurality of consensus mechanisms and a default consensus mechanism in an activated state are stored. First, if the current node device receives a consensus mechanism change instruction, the default consensus mechanism in the current node device is updated to the target consensus mechanism indicated by the consensus mechanism change instruction; and the node devices in the blockchain other than the current node device that are used to provide consensus sorting services are notified to update the default consensus mechanism to the target consensus mechanism. In this way, multiple consensus mechanisms are made compatible in the blockchain, so that the node devices in the blockchain can change the default consensus mechanism used to the target consensus mechanism according to the consensus mechanism change instruction and notification. Therefore, this method completes the replacement operation of the consensus mechanism without restarting the blockchain network, improves the flexibility of the consensus mechanism of the blockchain network, so that users can choose and replace different consensus mechanisms according to business needs, which is conducive to the further development of the blockchain ecology.

[0021] Other features and advantages of the present application will be described in the subsequent description, or some features and advantages can be inferred or determined without doubt from the description, or can be learned by implementing the above-mentioned technology of the present application.

[0022] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the following specifically cites preferred implementation modes and describes them in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the specific implementation methods of the present application or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0024] Figure 1 A flowchart of a method for processing a consensus mechanism in a blockchain provided in an embodiment of the present application;

[0025] Figure 2 A flowchart of another method for processing a consensus mechanism in a blockchain provided in an embodiment of the present application;

[0026] Figure 3 A flowchart of another method for processing a consensus mechanism in a blockchain provided in an embodiment of the present application;

[0027] Figure 4 A schematic diagram of the structure of a processing device for a consensus mechanism in a blockchain provided in an embodiment of the present application;

[0028] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0029] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.

[0030] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.

[0031] With the update of information technology, blockchain, as an emerging storage technology, has gradually become a hot topic. The blockchain network system is a data network system that uses cryptography to ensure the security of data transmission and access, and generates a distributed ledger that cannot be tampered with or forged. The advantage of blockchain lies in how to gain trust in a decentralized system, and the consensus mechanism, as the core part of gaining trust, reflects its irreplaceable advantage. The consensus mechanism refers to the process by which the nodes participating in the consensus in the blockchain network reach a consistent state. When the nodes in the network vote on the same transaction information, if a certain number (or all) of the nodes reach a consensus, then it can be said that the transaction has reached a consensus in the entire blockchain network.

[0032] There is no centralized institution like a bank in the blockchain network system, so when transmitting information and transferring value, the consensus mechanism ensures the consistency and correctness of each transaction on all accounting nodes. This new consensus mechanism of the blockchain enables it to operate efficiently and collaboratively on a large scale without relying on a centralized organization.

[0033] In the related technology, some blockchain networks, such as Hyperledger Fabric networks, can provide multiple consensus mechanisms. The internal consensus mechanism configuration has been completed before the blockchain network is started. For example, the corresponding consensus mechanism is configured when the genesis block is created, so that the nodes in the blockchain network need to verify and confirm the transactions generated within the blockchain network based on the consensus mechanism embedded in the blockchain network (equivalent to providing consensus sorting services). However, the above method cannot replace and modify the consensus mechanism after the blockchain network is successfully started, which makes it difficult to meet and adapt to the increasing and changing business needs of the blockchain network, and is not conducive to the expansion of the blockchain ecosystem.

[0034] Based on this, the embodiments of the present application provide a method, device and electronic device for processing the consensus mechanism in the blockchain. The technology can be applied to scenarios where the blockchain adopts a consensus mechanism to provide services, especially scenarios where the consensus mechanism is replaced to provide services. In order to facilitate the understanding of the embodiments of the present application, a method for processing the consensus mechanism in the blockchain disclosed in the embodiments of the present application is first introduced in detail. The method is applied to a node device in the blockchain, and the node device stores multiple consensus mechanisms and a default consensus mechanism in an activated state among the multiple consensus mechanisms; the default consensus mechanism is used to: provide consensus sorting services to the services received by the node device; such as Figure 1 As shown, the method comprises the following specific steps:

[0035] Step S102: If a consensus mechanism change instruction is received, the default consensus mechanism in the current node device is updated to the target consensus mechanism indicated by the consensus mechanism change instruction.

[0036] The above-mentioned blockchain includes multiple node devices, which can be electronic devices, mobile terminals (for example, mobile phones, tablet computers), computers, etc. Among the multiple node devices, there is a node device corresponding to an administrator, which is also the above-mentioned current node device. The administrator (that is, the user who has the authority to change the consensus mechanism) can store multiple consensus mechanisms on the current node device before starting the blockchain network, that is, the administrator can modify the configuration file (for example, node configuration file, channel configuration file, genesis block configuration file, etc.) in the current node device, and multiple consensus mechanisms can be added to the configuration file, and one of the consensus mechanisms can be selected as the default consensus mechanism according to demand or randomly, so that all node devices in the blockchain can use the default consensus mechanism to provide consensus sorting services for the received services after the blockchain network is started, which can also be understood as making the default consensus mechanism in an activated state.

[0037] The above consensus mechanisms may include Proof of Work (PoW), Proof of Stake (PoS), Delegated Proof of Stake (DPoS), Pool and Practical Byzantine Fault Tolerance (PBFT). Each consensus mechanism is applicable to different scenarios in the blockchain, and due to the theoretical limit of the consensus mechanism, different types of consensus mechanisms have certain advantages and disadvantages, so administrators need to select and replace different consensus mechanisms to meet current business needs.

[0038] The above PoW mechanism can be simply understood as a proof that the user has done a certain amount of work. Usually, by looking at the work results, it is possible to know what specified amount of work the user has completed. This PoW mechanism is also the most commonly used consensus mechanism in blockchain.

[0039] The above PoW mechanism has the following advantages: it is completely decentralized, and device nodes can enter and exit freely, avoiding the cost of establishing and maintaining centralized credit institutions; as long as the computing power of network destroyers does not exceed 50% of the total computing power of the entire network, the transaction status of the network can be consistent, and historical records cannot be tampered with; the more computing power is invested, the greater the probability of obtaining accounting rights, and the more likely it is to generate new block rewards. The PoW mechanism has the following disadvantages: mining currently causes a lot of computing power and energy waste; the incentive mechanism of mining causes a high concentration of mining computing power; the settlement cycle is long, and a maximum of 7 transactions are settled per second, which is not suitable for commercial applications.

[0040] The above PoS mechanism is similar to the dividend system of stocks. The more shares a person holds, the more dividends he or she can get. Currently, many digital assets use PoS to issue new coins. The advantages of this PoS mechanism are: it reduces the resource waste of the PoW mechanism; it speeds up the calculation speed, and can also be understood as an upgraded version of the proof-of-work mechanism. The disadvantages of this PoS mechanism are: the longer the coin age, the greater the probability that the device node will obtain the right to record accounts, which is likely to lead to the Matthew effect, that is, the rich get richer, which will lead to more and more concentrated rights and interests and poor fairness.

[0041] The above-mentioned DPoS mechanism can be a more professional solution derived from the PoS mechanism, similar to the board of directors voting, electing several agents, who are responsible for verification and bookkeeping. Unlike the PoW mechanism and the PoS mechanism, in which all nodes in the entire network can participate in the bookkeeping competition, the bookkeeping nodes of this DPoS mechanism are determined within a certain period of time. . The advantages of this DPoS mechanism are: compared with the PoW mechanism and the DPoS mechanism, the ability of the blockchain to process data is improved, and it can even achieve seconds to arrive, while also reducing the cost of maintaining the security of the blockchain network; the disadvantages of this DPoS mechanism are: the degree of decentralization is weak, the node agent is manually selected, and the fairness is lower than the PoS mechanism.

[0042] The above-mentioned Pool mechanism is usually based on traditional distributed consistency technology, plus a data verification mechanism, and is also a consensus mechanism currently widely used in industry blockchains. The advantages of this Pool are: it can achieve second-level consensus verification; the disadvantages of this Pool are: the degree of decentralization is weak, and it is more suitable for a multi-center business model with multi-party participation.

[0043] The above PBFT mechanism is usually that each "general" (a designated node on the blockchain) maintains an internal state (continuous specific information or state). When the "generals" receive messages, they use the message in conjunction with their internal state to run calculations or operations. This calculation in turn tells the "general" how to think about the information. Then, after reaching a personal decision about the new message, the "general" shares the decision with all other "generals" in the system, and finally determines the consensus decision based on all the decisions submitted by all the generals. The advantages of this PBFT mechanism are: PBFT requires two-to-two communication between all nodes, so this communication mechanism requires that the number of nodes cannot be too large, usually dozens. In this mode, nodes reach consensus faster and with lower latency; the control of the number of nodes allows the PBFT network to be free from being limited to the nodes with the lowest processing power like large PoW networks, so that the throughput of the entire network can be greatly improved. The disadvantages of this PBFT mechanism are: weak scalability and decentralization, and low fault tolerance.

[0044] From the above consensus mechanisms, we can see that each consensus mechanism cannot meet the requirements of security, efficiency, and fairness at the same time. The weaker the degree of decentralization, the lower the security and the faster the blockchain; the stronger the degree of decentralization, the higher the security and the slower the blockchain. Therefore, in the blockchain network, different consensus mechanisms need to be used according to different application scenarios to provide consensus sorting services for the businesses submitted to the blockchain.

[0045] When the consensus mechanism currently used by the blockchain cannot meet the needs of the business system, the administrator can replace the consensus mechanism according to the business needs, that is, the administrator selects and confirms the use of one of the multiple consensus mechanisms as the target consensus mechanism according to the current scenario type of the blockchain, the current network environment security and the business needs of the blockchain, and clicks or triggers the control corresponding to the consensus mechanism in the user operation interface to send a consensus mechanism change instruction to the current node device. When the current node device receives the consensus mechanism change instruction, the default consensus mechanism in the current node device is updated to the target consensus mechanism indicated by the consensus mechanism change instruction, so that the current node device adopts the target consensus mechanism to provide consensus sorting services for the business submitted to the current node device.

[0046] Step S104, notifying a designated device in the blockchain to update the default consensus mechanism in the designated device to the target consensus mechanism; wherein the designated device includes: a node device in the blockchain other than the current node device that is used to provide consensus sorting services.

[0047] When the current node device receives a consensus mechanism change instruction, it can not only update the default consensus mechanism in the current node device to the target consensus mechanism indicated by the consensus mechanism change instruction, but also notify the node devices on the blockchain other than the current node device that are used to provide consensus sorting services to change the default consensus mechanism to the target consensus mechanism, so that all node devices on the blockchain use the target consensus mechanism to provide consensus sorting services for the businesses submitted to the blockchain.

[0048] In the specific implementation, for the business (equivalent to transactions) submitted to the blockchain before updating to the target consensus mechanism, the default consensus mechanism is used to complete the consensus sorting service, and ensure that the data in all businesses can be normally uploaded to the chain; for transactions submitted to the blockchain after updating to the target consensus mechanism, the target consensus mechanism is used to complete the consensus sorting service, and ensure that the data in all businesses can be normally uploaded to the chain.

[0049] In the specific implementation, after the default consensus mechanism adopted on the blockchain is changed to the target consensus mechanism, if a consensus mechanism change instruction is received again, the consensus mechanism indicated in the consensus mechanism change instruction can be called the new target consensus mechanism, and the target consensus mechanism currently being adopted can be called the new default consensus mechanism, and the above steps S102-S104 can be continued to implement the change of the consensus mechanism.

[0050] The embodiment of the present application provides a method for processing a consensus mechanism in a blockchain. If the current node device in the blockchain receives a consensus mechanism change instruction, the default consensus mechanism in the current node device is updated to the target consensus mechanism indicated by the consensus mechanism change instruction; and the designated device of the node device other than the current node device in the blockchain that is used to provide consensus sorting services is notified to update the default consensus mechanism in the designated device to the target consensus mechanism. In this method, multiple consensus mechanisms are made compatible in the blockchain, so that the node devices in the blockchain can change the default consensus mechanism used to the target consensus mechanism according to the consensus mechanism change instruction and notification. Therefore, this method completes the replacement operation of the consensus mechanism without restarting the blockchain network, improves the flexibility of the consensus mechanism of the blockchain network, so that users can choose and replace different consensus mechanisms according to business needs, which is conducive to the further development of the blockchain ecology.

[0051] The embodiment of the present application also provides another method for processing the consensus mechanism in the blockchain, which is implemented on the basis of the method of the above embodiment; the method focuses on the specific process of initializing the multiple consensus mechanisms stored in the node device before the step of updating the default consensus mechanism in the current node device to the target consensus mechanism indicated by the consensus mechanism change instruction (implemented by the following steps S202-S204), such as Figure 2 As shown, the method comprises the following steps:

[0052] Step S202, initializing operations on multiple consensus mechanisms to obtain a consensus instance of each consensus mechanism; wherein the consensus instance is used to perform a consensus sorting operation.

[0053] Before starting the blockchain network, the administrator needs to modify the configuration file in the current node device, that is, add multiple consensus mechanisms that need to be initialized in the configuration file, and select one of the consensus mechanisms as the default consensus mechanism according to demand or randomly. In the specific implementation, the above-mentioned blockchain network can be a specified network; the multiple consensus mechanisms include: the inherent consensus mechanism of the specified network, and / or, the user-defined consensus mechanism. The specified network can be a Fabric network, so the multiple consensus mechanisms included in the configuration file can only include the inherent consensus mechanism of the Fabric network (for example, PoW mechanism, PoS mechanism, PBFT mechanism, etc.), can only include the user-defined consensus mechanism, or can include both the inherent consensus mechanism of the Fabric network and the user-defined consensus mechanism.

[0054] Usually, the above inherent consensus mechanism is created to solve specific problems and may not meet the needs of users. Therefore, users can define their own consensus mechanism and generate a custom consensus mechanism. The custom consensus mechanism can refer to the code written according to the user's business needs and can be executed by each node device in the blockchain network for transaction verification and confirmation, that is, the code that provides consensus sorting services.

[0055] In the process of starting the blockchain network, all consensus mechanisms set in the configuration file need to be initialized and consensus instances corresponding to each consensus mechanism need to be generated so that node devices can call the consensus mechanism to implement consensus sorting services.

[0056] In the specific implementation, for each of the multiple consensus mechanisms, the following steps 10-11 can be performed to obtain a consensus instance of each consensus mechanism:

[0057] Step 10, compile the code of the current consensus mechanism into an executable file; the code of the consensus mechanism is also the code that can implement the consensus sorting service corresponding to the consensus mechanism, and the code contains the parameters and conditions for the execution of the consensus mechanism. In the specific implementation, the executable file compiled into the code of the consensus mechanism is called a consensus mechanism plug-in, that is, the executable file can be configured in the node device of the blockchain in the form of a plug-in.

[0058] Step 11, setting initial values ​​for the parameters and / or conditions in the above executable file to obtain a consensus instance of the current consensus mechanism.

[0059] In the specific implementation, the blockchain network includes an initialization function of the consensus mechanism. When the consensus mechanism is deployed in the blockchain network, the initialization function is called by the consensus module in the blockchain network in the form of a function according to the current state of the blockchain network, and the consensus mechanism is initialized, that is, the parameters and / or conditions included in the executable file of the consensus mechanism are assigned initial values ​​to obtain a consensus instance of the consensus mechanism. In the specific implementation, when the consensus mechanism is initialized, only the parameters in the executable file can be assigned initial values, only the conditions in the executable file can be assigned initial values, or both the parameters in the executable file and the conditions in the executable file can be assigned initial values; the above process of initializing the consensus mechanism can also be understood as the process of instantiating the consensus mechanism.

[0060] Step S204, uploading the consensus instance of each consensus mechanism or the consensus instance of the default consensus mechanism to the ledger manager of the blockchain, so as to call the consensus instance of the default consensus mechanism from the ledger manager through the node device, and perform a consensus sorting operation on the business received by the node device.

[0061] The ledger manager in the above blockchain is usually used to manage the ledgers of each node device and the consensus mechanism of each node device, so that each node device can call the consensus instance of the consensus mechanism currently in the activated state from the ledger manager to provide consensus sorting services for the business currently received by the node device, that is, to perform consensus sorting operations on the currently received business. In specific implementation, the consensus instance of each consensus mechanism among the multiple consensus mechanisms obtained after initialization can be passed into the ledger manager of the blockchain, or only the consensus instance corresponding to the default consensus mechanism can be passed into the ledger manager of the blockchain, so that after the blockchain network is successfully started, the node devices on the blockchain can automatically select the default consensus mechanism when performing consensus sorting.

[0062] Step S206: If a consensus mechanism change instruction is received, query whether the ledger manager of the blockchain contains a consensus instance of the target consensus mechanism; if not, execute the following step S208; otherwise, execute step S210.

[0063] Step S208, upload the consensus instance of the target consensus mechanism to the ledger manager; and execute step S210.

[0064] The ledger manager of the above blockchain can store consensus instances of multiple consensus mechanisms. When receiving a consensus mechanism change instruction, in order to ensure that there is a consensus instance corresponding to the target consensus mechanism in the ledger manager, it is necessary to query whether the ledger manager of the blockchain contains the consensus instance of the target consensus mechanism. If not, it is necessary to return an instance upload request so that the administrator can trigger the instance upload control of the target consensus mechanism, so as to upload the consensus instance of the target consensus mechanism to the ledger manager through the trigger operation, so that the node devices in the subsequent blockchain can call the target consensus mechanism from the ledger manager to provide consensus sorting services.

[0065] Step S210, updating the default consensus mechanism in the current node device to the target consensus mechanism, and notifying the designated device in the blockchain to update the default consensus mechanism in the designated device to the target consensus mechanism; calling the consensus instance of the target consensus mechanism from the ledger manager to adopt the consensus instance of the target consensus mechanism to perform consensus sorting operations on the received business.

[0066] In some embodiments, after the default consensus mechanisms in the current device and the specified device are updated to the target consensus mechanism, it is necessary to query again whether the ledger manager contains a consensus instance of the target consensus mechanism to ensure the accuracy of the consensus mechanism call. If not, the consensus instance of the target consensus mechanism needs to be uploaded to the ledger manager. If it is included, the node device on the blockchain can call the consensus instance of the target consensus mechanism from the ledger manager to adopt the consensus instance of the target consensus mechanism to perform consensus sorting operations on the received business.

[0067] The above-mentioned method for handling the consensus mechanism in the blockchain can simultaneously initialize multiple consensus mechanisms before starting the blockchain network, and select one of the consensus mechanisms as the default consensus mechanism; when the default consensus mechanism cannot meet the user's business needs, the user can directly replace the consensus mechanism without changing the configuration and restarting the blockchain network, thereby realizing the pluggability of the blockchain consensus mechanism, improving the flexibility of the blockchain network consensus mechanism, and facilitating the further development of the blockchain ecology.

[0068] An embodiment of the present application also provides another method for processing a consensus mechanism in a blockchain, which is applied to a node device in a blockchain, wherein the node device includes a default consensus mechanism in an activated state; the default consensus mechanism is used to provide consensus sorting services to services received by the node device; the node device in this method is mainly used to update the default consensus mechanism in the current node device to the target consensus mechanism indicated by the notification if a notification of changing the consensus mechanism is received; wherein the notification is sent by a node device in the blockchain other than the current node device that is used to provide consensus sorting services.

[0069] In this embodiment, the current node device that receives the notification of changing the consensus mechanism is equivalent to any one of the designated devices in the above embodiments. The current node device can update the currently activated default consensus mechanism to the target consensus mechanism based on the received notification of changing the consensus mechanism.

[0070] In order to facilitate understanding of the embodiments of the present invention, the following focuses on describing the specific steps of updating the default consensus mechanism in the current node device to the target consensus mechanism indicated by the notification if the node device receives a notification of changing the consensus mechanism (specifically implemented by the following steps S302-S304), such as Figure 3 As shown, the process includes the following steps:

[0071] Step S302: If a notification of changing the consensus mechanism is received, an endorsement operation is performed on the notification to obtain an endorsement result; wherein the endorsement operation is used to verify whether the node device sending the notification is the designated node device.

[0072] In the specific implementation, the notification of changing the consensus mechanism carries the identity of the node device that sent the notification, and the node device that receives the notification of changing the consensus mechanism includes the identity of the node device that has the authority to send the notification of changing the consensus mechanism; if the current node device receives the notification of changing the consensus mechanism, it is necessary to match the identity carried in the notification with the identity saved by itself. If the match is successful, the endorsement result of successful endorsement by the current node device is obtained, otherwise the endorsement result of failed endorsement is obtained.

[0073] Step S304: If the endorsement result indicates that the node device sending the notification is a designated node device, the default consensus mechanism in the current node device is updated to the target consensus mechanism.

[0074] The node device specified above is the node device that has the authority to send notifications to change the consensus mechanism. The endorsement result indicates that the node device that sent the notification is the specified node device, which means that the endorsement is successful. It can also be understood that the identity carried in the notification matches the identity stored in the current node device. If the endorsement is successful, the default consensus mechanism in the current node device can be updated to the target consensus mechanism.

[0075] In some embodiments, in order to ensure the accuracy of endorsement, more than half of the node devices on the blockchain need to endorse successfully before the default consensus mechanism in the current node device can be updated to the target consensus mechanism.

[0076] In a specific implementation, the ledger manager of the blockchain stores consensus instances of multiple consensus mechanisms, and the consensus instances are used to perform consensus sorting operations; the above step S304 can also be implemented through the following steps 20-22:

[0077] Step 20, query whether the ledger manager contains the consensus instance of the target consensus mechanism; if not, execute step 21; if it is contained, execute step 22.

[0078] Step 21, sending a consensus instance upload instruction to the designated node device, so that the designated node device uploads the consensus instance of the target consensus mechanism to the ledger manager.

[0079] Step 22, calling the consensus instance of the target consensus mechanism from the ledger manager to adopt the consensus instance of the target consensus mechanism to perform a consensus sorting operation on the business received by the node device.

[0080] The above-mentioned method for processing the consensus mechanism in the blockchain makes multiple consensus mechanisms compatible in the blockchain and realizes the pluggability of the blockchain consensus mechanism, so that the consensus mechanism can be replaced without restarting the blockchain network, thereby improving the flexibility of the blockchain network consensus mechanism, allowing users to choose and replace different consensus mechanisms according to business needs, which is conducive to the further development of the blockchain ecology.

[0081] Corresponding to the above method embodiment, the embodiment of the present application provides a processing device for the consensus mechanism in the blockchain, which is arranged in a node device in the blockchain, and the node device stores a plurality of consensus mechanisms and a default consensus mechanism in an activated state among the plurality of consensus mechanisms; the default consensus mechanism is used to: provide a consensus sorting service to the business received by the node device; such as Figure 4 As shown, the device comprises:

[0082] The change instruction receiving module 40 is used to update the default consensus mechanism in the current node device to the target consensus mechanism indicated by the consensus mechanism change instruction if a consensus mechanism change instruction is received.

[0083] The mechanism change notification module 41 is used to notify the designated device in the blockchain to update the default consensus mechanism in the designated device to the target consensus mechanism; wherein the designated device includes: a node device in the blockchain, other than the current node device, for providing consensus sorting services.

[0084] The processing device of the consensus mechanism in the above-mentioned blockchain, if the current node device in the blockchain receives a consensus mechanism change instruction, updates the default consensus mechanism in the current node device to the target consensus mechanism indicated by the consensus mechanism change instruction; and notifies the designated device of the node device used to provide consensus sorting service in the blockchain other than the current node device, and updates the default consensus mechanism in the designated device to the target consensus mechanism. In this method, multiple consensus mechanisms are made compatible in the blockchain, so that the node devices in the blockchain can change the default consensus mechanism used to the target consensus mechanism according to the consensus mechanism change instruction and notification. Therefore, this method completes the replacement operation of the consensus mechanism without restarting the blockchain network, improves the flexibility of the consensus mechanism of the blockchain network, so that users can choose and replace different consensus mechanisms according to business needs, which is conducive to the further development of the blockchain ecology.

[0085] Specifically, the blockchain is a designated network; the multiple consensus mechanisms include: an inherent consensus mechanism of the designated network, and / or a user-defined consensus mechanism. In some embodiments, the designated network includes a Fabric network.

[0086] Furthermore, the above-mentioned device also includes an initialization module, which is used to: perform initialization operations on multiple consensus mechanisms to obtain a consensus instance of each consensus mechanism; wherein the consensus instance is used to perform a consensus sorting operation.

[0087] Specifically, the above initialization module is also used to: for each consensus mechanism among the multiple consensus mechanisms, perform the following operations: compile the code of the current consensus mechanism into an executable file; set initial values ​​for the parameters and / or conditions in the executable file to obtain a consensus instance of the current consensus mechanism.

[0088] Furthermore, the above-mentioned device also includes a consensus instance uploading module, which is used to: upload the consensus instance of each consensus mechanism or the consensus instance of the default consensus mechanism to the ledger manager of the blockchain, so as to call the consensus instance of the default consensus mechanism from the ledger manager through the node device, and perform consensus sorting operations on the services received by the node device.

[0089] In a specific implementation, the ledger manager of the above-mentioned blockchain stores consensus instances of multiple consensus mechanisms, and the consensus instances are used to perform consensus sorting operations; the above-mentioned device also includes an instance query module, which is used to query whether the ledger manager contains the consensus instance of the target consensus mechanism; if the consensus instance of the target consensus mechanism is not contained, the consensus instance of the target consensus mechanism is uploaded to the ledger manager.

[0090] Furthermore, the above-mentioned device also includes an instance calling module, which is used to query whether the consensus instance of the target consensus mechanism is included in the ledger manager; if the consensus instance of the target consensus mechanism is included, the consensus instance of the target consensus mechanism is called from the ledger manager to adopt the consensus instance of the target consensus mechanism to perform consensus sorting operations on the services received by the node device.

[0091] The processing device for the consensus mechanism in the blockchain provided in the embodiment of the present application has the same implementation principle and technical effects as those in the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the device embodiment, reference may be made to the corresponding contents in the aforementioned method embodiment.

[0092] Corresponding to the above method embodiment, the embodiment of the present application also provides another device for processing a consensus mechanism in a blockchain, which is arranged in a node device in the blockchain, and the node device includes a default consensus mechanism in an activated state; the default consensus mechanism is used to: provide consensus sorting services to the services received by the node device; the device includes: a mechanism change module, which is used to update the default consensus mechanism in the current node device to the target consensus mechanism indicated by the notification if a notification of changing the consensus mechanism is received; wherein the notification is sent by a node device in the blockchain, other than the current node device, for providing consensus sorting services.

[0093] Furthermore, the above-mentioned mechanism change module includes: an endorsement unit, which is used to endorse the notification and obtain an endorsement result; wherein the endorsement operation is used to verify whether the node device sending the notification is a designated node device; the mechanism change unit is used to update the default consensus mechanism in the current node device to the target consensus mechanism if the endorsement result indicates that the node device sending the notification is a designated node device.

[0094] Specifically, the ledger manager of the above-mentioned blockchain stores consensus instances of multiple consensus mechanisms, and the consensus instances are used to perform consensus sorting operations; the above-mentioned mechanism change unit is used to query whether the consensus instance of the target consensus mechanism is included in the ledger manager; if the consensus instance of the target consensus mechanism is not included in the ledger manager, a consensus instance upload instruction is sent to the specified node device so that the specified node device uploads the consensus instance of the target consensus mechanism to the ledger manager; if the ledger manager contains the consensus instance of the target consensus mechanism, the consensus instance of the target consensus mechanism is called from the ledger manager to adopt the consensus instance of the target consensus mechanism to perform consensus sorting operations on the services received by the node device.

[0095] The processing device of the consensus mechanism in the above-mentioned blockchain realizes the compatibility of multiple consensus mechanisms in the blockchain and realizes the pluggability of the blockchain consensus mechanism, so that the consensus mechanism replacement operation is completed without restarting the blockchain network, thereby improving the flexibility of the blockchain network consensus mechanism, allowing users to choose and replace different consensus mechanisms according to business needs, which is conducive to the further development of the blockchain ecology.

[0096] The present application also provides an electronic device for running the above-mentioned blockchain consensus mechanism processing method, see Figure 5 As shown, the electronic device includes a processor 101 and a memory 100, wherein the memory 100 stores machine executable instructions that can be executed by the processor 101, and the processor 101 executes the machine executable instructions to implement the processing method of the consensus mechanism in the above-mentioned blockchain.

[0097] Further, Figure 5 The electronic device shown further includes a bus 102 and a communication interface 103 , and the processor 101 , the communication interface 103 and the memory 100 are connected via the bus 102 .

[0098] The memory 100 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 103 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used. The bus 102 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0099] The processor 101 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 101. The above processor 101 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 100, and the processor 101 reads the information in the memory 100 and completes the steps of the method of the above embodiment in combination with its hardware.

[0100] The embodiment of the present application also provides a machine-readable storage medium, which stores machine-executable instructions. When the machine-executable instructions are called and executed by the processor, the machine-executable instructions prompt the processor to implement the processing method of the consensus mechanism in the above-mentioned blockchain. The specific implementation can be found in the method embodiment, which will not be repeated here.

[0101] The computer program product of the method, device and electronic device for processing the consensus mechanism in the blockchain provided in the embodiments of the present application includes a computer-readable storage medium storing program code, and the instructions included in the program code can be used to execute the method described in the previous method embodiments. The specific implementation can be found in the method embodiments, which will not be repeated here.

[0102] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, an electronic device, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0103] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims

1. A method for processing a consensus mechanism in a blockchain, characterized in that: The method is applied to a node device in a blockchain, wherein the node device stores a plurality of consensus mechanisms and a default consensus mechanism in an activated state among the plurality of consensus mechanisms; The default consensus mechanism is used to provide consensus sorting services to the services received by the node device; the method includes: If a consensus mechanism change instruction is received, the default consensus mechanism in the current node device is updated to the target consensus mechanism indicated by the consensus mechanism change instruction; Notifying a designated device in the blockchain to update the default consensus mechanism in the designated device to the target consensus mechanism; wherein the designated device includes: a node device in the blockchain other than the current node device that is used to provide consensus sorting services; The blockchain ledger manager stores the consensus instances of the multiple consensus mechanisms, and the consensus instances are used to perform consensus sorting operations; before the step of updating the default consensus mechanism in the current node device to the target consensus mechanism indicated by the consensus mechanism change instruction, the method includes: querying whether the ledger manager contains the consensus instance of the target consensus mechanism; if the consensus instance of the target consensus mechanism is not contained, uploading the consensus instance of the target consensus mechanism to the ledger manager; For each consensus mechanism among the multiple consensus mechanisms, the following steps are performed to obtain a consensus instance of each consensus mechanism: compiling the code of the current consensus mechanism into an executable file; wherein the code of the consensus mechanism is a code for implementing the consensus sorting service corresponding to the consensus mechanism, and the code contains parameters and conditions for the execution of the consensus mechanism; setting initial values ​​for the parameters and / or conditions in the executable file to obtain a consensus instance of the current consensus mechanism.

2. The method according to claim 1, characterized in that The blockchain is a designated network; the multiple consensus mechanisms include: an inherent consensus mechanism of the designated network, and / or a user-defined consensus mechanism.

3. The method according to claim 1, characterized in that After the step of initializing the multiple consensus mechanisms to obtain a consensus instance of each consensus mechanism, the method further includes: The consensus instance of each consensus mechanism or the consensus instance of the default consensus mechanism is uploaded to the ledger manager of the blockchain, so that the consensus instance of the default consensus mechanism is called from the ledger manager through the node device to perform a consensus sorting operation on the business received by the node device.

4. The method according to claim 1, characterized in that: The blockchain ledger manager stores consensus instances of the multiple consensus mechanisms, and the consensus instances are used to perform consensus sorting operations; After the step of updating the default consensus mechanism in the current node device to the target consensus mechanism indicated by the consensus mechanism change instruction, the method further includes: Querying whether the ledger manager contains a consensus instance of the target consensus mechanism; If a consensus instance of the target consensus mechanism is included, the consensus instance of the target consensus mechanism is called from the ledger manager to adopt the consensus instance of the target consensus mechanism to perform a consensus sorting operation on the business received by the node device.

5. A method for processing a consensus mechanism in a blockchain, characterized in that: The method is applied to a node device in a blockchain, wherein the node device includes a default consensus mechanism in an activated state; The default consensus mechanism is used to provide consensus sorting services to the services received by the node device; the method includes: If a notification of changing the consensus mechanism is received, the default consensus mechanism in the current node device is updated to the target consensus mechanism indicated by the notification; The notification is sent by a node device in the blockchain, other than the current node device, that is used to provide consensus sorting services; the ledger manager of the blockchain stores consensus instances of multiple consensus mechanisms, and the consensus instances are used to perform consensus sorting operations; the node device in the blockchain queries whether the ledger manager contains the consensus instance of the target consensus mechanism; if the consensus instance of the target consensus mechanism is not contained, the consensus instance of the target consensus mechanism is uploaded to the ledger manager; For each consensus mechanism among the multiple consensus mechanisms, the following steps are performed to obtain a consensus instance of each consensus mechanism: compiling the code of the current consensus mechanism into an executable file; wherein the code of the consensus mechanism is a code for implementing the consensus sorting service corresponding to the consensus mechanism, and the code contains parameters and conditions for the execution of the consensus mechanism; setting initial values ​​for the parameters and / or conditions in the executable file to obtain a consensus instance of the current consensus mechanism.

6. The method according to claim 5, characterized in that If a notification of changing the consensus mechanism is received, the step of updating the default consensus mechanism in the current node device to the target consensus mechanism indicated by the notification includes: Performing an endorsement operation on the notification to obtain an endorsement result; wherein the endorsement operation is used to verify whether the node device sending the notification is a designated node device; If the endorsement result indicates that the node device sending the notification is the designated node device, the default consensus mechanism in the current node device is updated to the target consensus mechanism.

7. The method according to claim 6, characterized in that The blockchain ledger manager stores consensus instances of multiple consensus mechanisms, and the consensus instances are used to perform consensus sorting operations; If the endorsement result indicates that the node device sending the notification is the designated node device, the step of updating the default consensus mechanism in the current node device to the target consensus mechanism includes: Querying whether the ledger manager contains a consensus instance of the target consensus mechanism; If the ledger manager does not contain a consensus instance of the target consensus mechanism, sending a consensus instance upload instruction to the designated node device so that the designated node device uploads the consensus instance of the target consensus mechanism to the ledger manager; If the ledger manager includes a consensus instance of the target consensus mechanism, the consensus instance of the target consensus mechanism is called from the ledger manager to adopt the consensus instance of the target consensus mechanism to perform a consensus sorting operation on the business received by the node device.

8. A processing device for a consensus mechanism in a blockchain, characterized in that: The device is arranged in a node device in a blockchain, wherein the node device stores a plurality of consensus mechanisms and a default consensus mechanism in an activated state among the plurality of consensus mechanisms; The default consensus mechanism is used to provide consensus sorting services to the services received by the node device; the device includes: A change instruction receiving module is used to update the default consensus mechanism in the current node device to the target consensus mechanism indicated by the consensus mechanism change instruction if a consensus mechanism change instruction is received; A mechanism change notification module, used to notify a designated device in the blockchain to update the default consensus mechanism in the designated device to the target consensus mechanism; wherein the designated device includes: a node device in the blockchain other than the current node device that is used to provide consensus sorting services; The blockchain ledger manager stores the consensus instances of the multiple consensus mechanisms, and the consensus instances are used to perform consensus sorting operations; an instance query module is used to query whether the ledger manager contains the consensus instance of the target consensus mechanism; if the consensus instance of the target consensus mechanism is not contained, the consensus instance of the target consensus mechanism is uploaded to the ledger manager; For each consensus mechanism among the multiple consensus mechanisms, the following steps are performed to obtain a consensus instance of each consensus mechanism: compiling the code of the current consensus mechanism into an executable file; wherein the code of the consensus mechanism is a code for implementing the consensus sorting service corresponding to the consensus mechanism, and the code contains parameters and conditions for the execution of the consensus mechanism; setting initial values ​​for the parameters and / or conditions in the executable file to obtain a consensus instance of the current consensus mechanism.

9. A processing device for a consensus mechanism in a blockchain, characterized in that: The device is arranged in a node device in a blockchain, and the node device includes a default consensus mechanism in an activated state; The default consensus mechanism is used to provide consensus sorting services to the services received by the node device; the device includes: A mechanism changing module, configured to update the default consensus mechanism in the current node device to the target consensus mechanism indicated by the notification if a notification of changing the consensus mechanism is received; The notification is sent by a node device in the blockchain, other than the current node device, that is used to provide consensus sorting services; the ledger manager of the blockchain stores consensus instances of multiple consensus mechanisms, and the consensus instances are used to perform consensus sorting operations; the node device in the blockchain queries whether the ledger manager contains the consensus instance of the target consensus mechanism; if the consensus instance of the target consensus mechanism is not contained, the consensus instance of the target consensus mechanism is uploaded to the ledger manager; For each consensus mechanism among the multiple consensus mechanisms, the following steps are performed to obtain a consensus instance of each consensus mechanism: compiling the code of the current consensus mechanism into an executable file; wherein the code of the consensus mechanism is a code for implementing the consensus sorting service corresponding to the consensus mechanism, and the code contains parameters and conditions for the execution of the consensus mechanism; setting initial values ​​for the parameters and / or conditions in the executable file to obtain a consensus instance of the current consensus mechanism.

10. An electronic device, characterized in that: It includes a processor and a memory, the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the processing method of the consensus mechanism in the blockchain according to any one of claims 1 to 7.

11. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores machine-executable instructions. When the machine-executable instructions are called and executed by the processor, the machine-executable instructions prompt the processor to implement the method for processing the consensus mechanism in the blockchain as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Consensus mechanism control method and related equipment

    CN110944046A