WO2023185059A1 - Consensus method and blockchain node - Google Patents

Consensus method and blockchain node Download PDF

Info

Publication number
WO2023185059A1
WO2023185059A1 PCT/CN2022/135666 CN2022135666W WO2023185059A1 WO 2023185059 A1 WO2023185059 A1 WO 2023185059A1 CN 2022135666 W CN2022135666 W CN 2022135666W WO 2023185059 A1 WO2023185059 A1 WO 2023185059A1
Authority
WO
WIPO (PCT)
Prior art keywords
node
consensus
nodes
information
delegation
Prior art date
Application number
PCT/CN2022/135666
Other languages
French (fr)
Chinese (zh)
Inventor
石杰
徐文博
邓福喜
闫莺
Original Assignee
蚂蚁区块链科技(上海)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 蚂蚁区块链科技(上海)有限公司 filed Critical 蚂蚁区块链科技(上海)有限公司
Publication of WO2023185059A1 publication Critical patent/WO2023185059A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/104Peer-to-peer [P2P] networks
    • H04L67/1087Peer-to-peer [P2P] networks using cross-functional networking aspects
    • H04L67/1093Some peer nodes performing special functions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/104Peer-to-peer [P2P] networks
    • H04L67/1042Peer-to-peer [P2P] networks using topology management mechanisms
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3247Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials involving digital signatures
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L2209/00Additional information or applications relating to cryptographic mechanisms or cryptographic arrangements for secret or secure communication H04L9/00
    • H04L2209/46Secure multiparty computation, e.g. millionaire problem
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L2209/00Additional information or applications relating to cryptographic mechanisms or cryptographic arrangements for secret or secure communication H04L9/00
    • H04L2209/46Secure multiparty computation, e.g. millionaire problem
    • H04L2209/463Electronic voting

Definitions

  • the embodiments of this specification belong to the field of blockchain technology, and particularly relate to a consensus method and blockchain nodes.
  • Blockchain is a new application model of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm.
  • data blocks are combined into a chained data structure in a chronological manner and are cryptographically guaranteed to be an untamperable and unforgeable distributed ledger. Due to the characteristics of blockchain, such as decentralization, non-tamperable information, and autonomy, blockchain has also received more and more attention and applications.
  • the purpose of the present invention is to provide a consensus solution to improve the consensus efficiency in the blockchain.
  • a first aspect of this specification provides a consensus method, which is executed by a first node in a blockchain.
  • the blockchain includes multiple consensus nodes, and the first node is one of the multiple consensus nodes.
  • the method includes: obtaining entrustment information from the blockchain, the entrustment information is used to indicate the number of entrustment nodes associated with each of the consensus nodes, and the entrustment node is the entrustment of any of the consensus nodes in the blockchain.
  • Consensus node performs consensus operations on consensus proposals based on the delegation information.
  • a second aspect of this specification provides a consensus node, including: an acquisition unit, configured to acquire delegation information from a blockchain, where the delegation information is used to indicate the number of delegation nodes associated with each consensus node, and the delegation node It is a node in the blockchain that entrusts any of the consensus nodes to carry out consensus; a consensus unit is used to perform consensus operations on consensus proposals based on the entrustment information.
  • a third aspect of this specification provides a computer-readable storage medium on which a computer program is stored.
  • the computer program is executed in a computer, the computer is caused to execute the method described in the first aspect.
  • a fourth aspect of this specification provides a consensus node, including a memory and a processor.
  • the memory stores executable code.
  • the processor executes the executable code, the method described in the first aspect is implemented.
  • the number of nodes participating in the consensus is reduced to a smaller number, the consensus time is reduced, the consensus efficiency is improved, the amount of consensus communication data is reduced, and the cost is reduced.
  • Figure 1 is a blockchain architecture diagram in an embodiment
  • FIG. 2 is a schematic diagram of the consensus process in the PBFT consensus algorithm in an embodiment
  • Figure 3 is a flow chart of a method for entrusting nodes to perform consensus in the blockchain in an embodiment of this specification
  • FIG. 4 is a flow chart of the consensus method in an embodiment of this specification.
  • Figure 5 is a flow chart of a method for setting up malicious nodes in the blockchain in an embodiment of this specification
  • Figure 6 is a flowchart of a method for canceling delegation to a consensus node when a consensus node fails in an embodiment of this specification
  • FIG. 7 is a structural diagram of a consensus node in an embodiment of this specification.
  • Blockchains are generally divided into three types: Public Blockchain, Private Blockchain and Consortium Blockchain.
  • public chains are represented by Bitcoin and Ethereum. Participants who join the public chain can read data records on the chain, participate in transactions, and compete for the accounting rights of new blocks through consensus.
  • the alliance chain is a blockchain between the public chain and the private chain, which can achieve "partial decentralization". Each node in the alliance chain usually has a corresponding entity or organization; participants join the network through authorization and form a stakeholder alliance to jointly maintain the operation of the blockchain.
  • FIG. 1 shows a blockchain architecture diagram in an embodiment.
  • the blockchain 100 includes, for example, a total of 7 nodes from node 1 to node 7.
  • the connections between nodes schematically represent P2P (Peer to Peer, point-to-point) connections.
  • P2P Peer to Peer, point-to-point
  • These nodes can store the entire ledger, that is, store the status of all blocks and all accounts.
  • each node in the blockchain can generate the same state in the blockchain by executing the same transaction, and each node in the blockchain can store the same state database.
  • FIG. 1 shows that the blockchain includes 7 nodes, the embodiments of this description are not limited to this, and may include other numbers of nodes.
  • the nodes included in the blockchain can meet Byzantine Fault Tolerance (BFT) requirements.
  • BFT Byzantine Fault Tolerance
  • the mentioned Byzantine fault tolerance requirements can be understood as meaning that Byzantine nodes can exist within the blockchain, but the blockchain does not reflect Byzantine behavior externally.
  • some Byzantine fault-tolerant algorithms require the number of nodes to be greater than 3f+1, where f is the number of Byzantine nodes (i.e. malicious nodes), such as the Practical Byzantine Fault Tolerance algorithm PBFT (Practical Byzantine Fault Tolerance).
  • Transactions in the blockchain field can refer to task units that are executed and recorded in the blockchain. Transactions usually include sending fields (From), receiving fields (To) and data fields (Data). Among them, when the transaction is a transfer transaction, the From field represents the account address that initiated the transaction (that is, initiated a transfer task to another account), the To field represents the account address that received the transaction (that is, received the transfer), and the Data field Include transfer amount.
  • the From field indicates the account address that initiated the transaction
  • the To field indicates the account address of the contract called by the exchange
  • the Data field includes the function name in the calling contract and the corresponding Data such as the incoming parameters of the function are used to obtain the code of the function from the blockchain and execute the code of the function when the transaction is executed.
  • Smart contracts on the blockchain are contracts that can be triggered and executed by transactions on the blockchain system. Smart contracts can be defined in the form of code. Calling a smart contract in the blockchain is to initiate a transaction pointing to the smart contract address, allowing each node in the blockchain to run the smart contract code in a distributed manner. It should be noted that in addition to smart contracts that can be created by users, smart contracts can also be set by the system in the genesis block. This type of contract is generally called a creation contract. Generally, some blockchain data structures, parameters, properties and methods can be set in the genesis contract. In addition, accounts with system administrator rights can create system-level contracts or modify system-level contracts (referred to as system contracts). Among them, the system contract can be used to add data structures for different business data in the blockchain.
  • Bob sends a transaction containing information about creating a smart contract (i.e., deploying the contract) to the blockchain as shown in Figure 1.
  • the data field of the transaction includes the code of the contract to be created (such as bytecode or machine code), the to field of the transaction is empty to indicate that the transaction is used to deploy the contract.
  • the contract address "0x6f8ae93" of the contract is determined.
  • Each node adds the contract account corresponding to the contract address of the smart contract in the state database, allocates the state storage corresponding to the contract account, and stores The contract code is saved in the state storage of the contract, so the contract is created successfully.
  • each node in the blockchain can execute the transaction respectively, thereby executing the contract respectively, and update the status database based on the execution of the contract.
  • a transaction-granularity consensus mechanism can be implemented between blockchain nodes. For example, after a node (such as a unique node) obtains a blockchain transaction, if the blockchain transaction is recognized by other nodes, Each node that recognizes the blockchain transaction can add the blockchain transaction to the latest block maintained by itself, and ultimately ensure that each node generates the same latest block.
  • the consensus mechanism is a mechanism for blockchain nodes to reach a consensus across the entire network on block information (or block data), which can ensure that the latest blocks are accurately added to the blockchain.
  • the current mainstream consensus mechanisms include: Proof of Work (POW), Proof of Stake (POS), Delegated Proof of Stake (DPOS), Practical Byzantine Fault Tolerance (PBFT) ) algorithm, etc.
  • PW Proof of Work
  • POS Proof of Stake
  • DPOS Delegated Proof of Stake
  • PBFT Practical Byzantine Fault Tolerance
  • N the number of nodes reach an agreement on the consensus data
  • f malicious nodes can be tolerated. That is to say, when 2f + 1 nodes among the N consensus nodes reach an agreement, the consensus can be determined to be successful.
  • FIG. 2 is a schematic diagram of the consensus process in the PBFT consensus algorithm.
  • the consensus process can be divided into four stages: Request, Pre-Prepare, Prepare and Commit.
  • a blockchain includes four consensus nodes, node n1 - node n4, where node n1 is, for example, the master node, and node n2 - node n4, for example, are slave nodes.
  • the user of the blockchain can send a request to the node n1 through its user device, and the request is, for example, in the form of a blockchain transaction.
  • node n1 can package the multiple transactions into a consensus proposal, and send the consensus proposal and node n1's signature to the consensus proposal to other consensus nodes. (i.e., node n2 - node n4) to generate blocks.
  • the consensus proposal may include information such as the transaction body of the multiple transactions and the submission order of the multiple transactions.
  • each slave node can sign the consensus proposal and send it to each other node.
  • node n1 receives the signatures of node n2 and node n3
  • node n2 is After receiving the signature of node n3 and the signature of node n1 in the preparation phase and passing the verification, it is determined that the preparation phase is completed.
  • each consensus node signs the consensus proposal in the submission phase and sends it to each other consensus node.
  • each consensus node can confirm that the submission phase is completed and the consensus success. For example, after receiving and verifying the signatures of the submission phase of node n2 and node n3, node n1 determines that the submission phase is completed. Therefore, node n1 can execute the multiple transactions according to the consensus proposal, generate and store the multiple transactions including the multiple transactions.
  • the transaction block (for example, block B1) updates the world state based on the execution results of multiple transactions and returns the execution results of multiple transactions to the user device.
  • node n2 and node n3 execute the multiple transactions, generate and store block B1, and update the world state according to the execution results of the multiple transactions.
  • the storage consistency of node n1, node n2 and node n3 is achieved.
  • nodes n1-node n4 can still achieve successful consensus on the consensus proposal and complete the execution of the block even if there is a malicious node.
  • the embodiment of this specification proposes a solution for converging the scale of consensus nodes through a delegation mechanism.
  • This solution can reasonably utilize some trust relationships between nodes in actual projects and support stable consensus of large-scale nodes.
  • Figure 3 is a flow chart of a method for entrusting nodes to perform consensus in the blockchain in an embodiment of this specification.
  • step S301 node 5 sends transaction Tx1 to the blockchain to entrust node 2 to carry out consensus.
  • node 5 can send a transaction Tx1 for delegation to the blockchain, entrusting node 2 to perform consensus on behalf of node 5.
  • Node 5 and node 2 may be, for example, two nodes in the same organization.
  • node 5 can generate transaction Tx1, which can be used to call the pre-deployed smart contract C1 in the blockchain to record delegation information in the blockchain.
  • node 5 can send transaction Tx1 to any node in the blockchain (for example, node 1) to achieve consensus and execution in the blockchain through the process shown in Figure 2.
  • step S303 the node in the blockchain executes the transaction Tx1 and records the delegation information in the blockchain.
  • nodes 1 to 7 in the blockchain are currently consensus nodes.
  • Each consensus node in the blockchain is proposing consensus on the consensus corresponding to the block where transaction Tx1 is located (for example, block B1).
  • transaction Tx1 is executed respectively, and the world state is updated based on the execution result of transaction Tx1.
  • node 1 can record the commission information in the contract status of contract C1.
  • a consensus node information table may be stored in the contract state of contract C1. Before executing transaction Tx1, the consensus node information table is, for example, as shown in Table 1:
  • Consensus node Weights Delegate node Node 1 1 Node 2 1 Node 3 1 Node 4 1 Node 5 1 Node 6 1 Node 7 1
  • Table 1 shows that nodes 1 to 7 are all consensus nodes, and their entrusted node columns are all empty, indicating that no other node has entrusted them to perform consensus on their behalf.
  • a weight of 1 indicates that each consensus node currently only performs consensus on its own behalf.
  • Consensus node Weights Delegate node Node 1 1 Node 2 2 Node 5
  • Consensus node Weights Delegate node Node 1 1 Node 2 3 Node 5, Node 6 Node 3 2 Node 7 Node 4 1
  • Node 1-Node 4 can calculate the number of signatures based on the weight, thereby performing consensus on behalf of the entrusted node.
  • the contract status of contract C1 also includes a delegation node information table.
  • the delegation node information table includes, for example, the identification of the node that entrusts other nodes to perform consensus and the identification of the corresponding trusted node. After executing each transaction for the entrusted node, the node in the blockchain also updates the entrusted node information table in the contract status of contract C1. For example,
  • node 1 After node 1 executes the above transaction Tx3, it can generate the entrusted node information table as shown in Table 4:
  • the delegation information recorded in the blockchain is not limited to the above. As long as the delegation information can indicate the number of delegation nodes corresponding to each consensus node, the consensus provided by the embodiments of this specification can be executed. method.
  • FIG. 4 is a flow chart of a consensus method in an embodiment of this specification. This consensus method can be executed by any consensus node in the blockchain, specifically including the following steps:
  • Step S401 obtain delegation information from the blockchain
  • Step S403 Perform consensus operation based on delegation information.
  • each consensus node obtains the delegation information in the blockchain.
  • the delegation information includes, for example, the consensus node information table shown in Table 3 of the contract status of contract C1 in node 1.
  • node 1 is the master node among multiple consensus nodes.
  • node 1 in the request phase, node 1 generates a consensus proposal after receiving multiple transactions from one or more user devices.
  • the consensus proposal includes, for example, the generation Multiple transactions in block B2 and the submission order of the multiple transactions.
  • Node 1 In order to reach consensus with the consensus nodes in the blockchain, Node 1 needs to obtain the information of each consensus node in the blockchain. Therefore, node 1 can read the consensus node information table shown in Table 3 from the blockchain. Specifically, node 1 can initiate a query request (or query transaction) for calling contract C1, thereby querying the current consensus node information table of contract C1 locally.
  • each consensus node performs a consensus operation based on the delegation information.
  • node 1 sends the consensus proposal and node 1's signature of the consensus proposal to node 2, node 3 and node 4 respectively based on the identification of each consensus node in Table 3.
  • node 2, node 3 and node 4 respectively sign the consensus proposal and send the consensus proposal and its signature to other consensus nodes respectively.
  • node 1 receives the signatures of node 2 and node 3 on the consensus proposal.
  • Node 3 and Node 4 may similarly determine that the preliminary phase is complete.
  • Node 1-Node 4 respectively send the signatures of the consensus proposal in the preparation phase to other consensus nodes in Table 3.
  • Each consensus node can similarly determine the number of signatures obtained according to Table 3. When the number of signatures is greater than or equal to 5, it can be determined that the preparation phase is completed, and therefore the consensus process for block B2 is completed.
  • each consensus node may broadcast a block synchronization event to each node of the blockchain after generating block B2. After the delegated node receives the event, it synchronizes block B2 from its delegated consensus node.
  • the entrusting node can periodically send query requests to the consensus node it entrusts to query the block height of the consensus node. When it is found that the block height of the consensus node is higher than its own block height, the entrusted consensus node can Nodes synchronize new blocks.
  • each consensus node can record information such as the identity of the source node of each received signature in the log, so that a fork occurs when a consensus proposal is received (that is, different consensus proposals and their signatures are received) In this case, the malicious nodes among the consensus nodes can be locked based on the logs.
  • the consensus node After the consensus node identifies a malicious node, it can limit its participation in the consensus by recording the malicious node and its delegated nodes in the blockchain.
  • Figure 5 is a flow chart of a method for setting up malicious nodes in the blockchain according to an embodiment of this specification.
  • node 4 determines that node 3 is a malicious node during the consensus process.
  • node 4 can determine that the weight of node 3 is 2, which is what the above-mentioned blockchain can tolerate. The number of malicious nodes, therefore, node 3 can be set as a malicious node through consensus in this blockchain.
  • step S501 node 4 sends transaction Tx4 to node 1.
  • Transaction Tx4 can be used to call the above smart contract to set node 3 as a malicious node in the blockchain.
  • step S503 the consensus node in the blockchain executes transaction Tx4 and updates the delegation information in the blockchain.
  • the consensus nodes can monitor each other's operating status, or the entrusting node can monitor the status of the entrusted consensus node after entrusting the consensus node.
  • a transaction can be sent to the blockchain to cancel the entrustment. Delegation of nodes to consensus nodes.
  • Figure 6 is a flowchart of a method for canceling delegation to a consensus node when a consensus node fails in an embodiment of this specification.
  • node 4 can send a transaction Tx5 that calls the above contract C1 to node 1 to cancel the entrustment of node 3 by the entrusting node (ie node 7). .
  • step S603 node 1 executes transaction Tx5 and updates the delegation information.
  • FIG. 7 is a structural diagram of a consensus node in an embodiment of this specification, including:
  • the acquisition unit 71 is used to acquire the entrustment information of multiple consensus nodes from the blockchain.
  • the entrustment information is used to indicate the number of entrustment nodes associated with each consensus node.
  • the entrustment node is in the blockchain. A node that entrusts any of the consensus nodes to carry out consensus;
  • the consensus unit 72 is configured to perform a consensus operation on the consensus proposal based on the delegation information.
  • the consensus node further includes: a receiving unit, configured to receive a first transaction, the first transaction being sent by a second node among the plurality of consensus nodes, and used to entrust the plurality of consensus nodes to The third node among the consensus nodes performs consensus; an update unit is used to update the delegation information according to the first transaction.
  • the delegation information includes a consensus node information table.
  • the consensus node information table includes the identification and weight of each consensus node.
  • the weight is used to indicate the delegation node associated with each consensus node.
  • the update unit is specifically configured to: delete the information of the second node in the consensus node information table, and increase the weight of the third node by one.
  • the delegation information further includes a delegation node information table
  • the update unit is specifically configured to record the delegation of the second node to the third node in the delegation node information table.
  • the consensus unit 72 is specifically configured to: generate its own signature for the consensus proposal, receive the signatures of the other consensus nodes for the consensus proposal from other consensus nodes, and generate The weight information is used to calculate the number of signatures obtained for the consensus proposal, and whether the consensus is successful is confirmed based on the number of signatures.
  • the delegation information of the first node also includes an identification of a fourth node that delegates the first node
  • the consensus node further includes: a generating unit for proposing a consensus on the consensus. After success, the first block is generated according to the consensus proposal, and the first block is sent to the fourth node.
  • the blockchain includes a smart contract
  • the delegation information is stored in a contract state of the smart contract
  • the first transaction calls the smart contract.
  • the delegation information further includes a malicious node list
  • the receiving unit is further configured to: receive a second transaction, where the second transaction is used to indicate that the fifth node among the plurality of consensus nodes is Malicious node
  • the update unit is also configured to: execute the second transaction, delete the information of the fifth node in the consensus node information table, and add the identification of the fifth node to the malicious node list The identifier of the delegation node associated with the fifth node.
  • the receiving unit is further configured to receive a third transaction, the third transaction is used to indicate that the sixth node among the plurality of consensus nodes is a fault node, and execute the third transaction, To delete the information of the sixth node in the consensus node information table, and add the identification and weight of the delegation node associated with the sixth node in the consensus node information table.
  • PLD Programmable Logic Device
  • FPGA Field Programmable Gate Array
  • HDL Hardware Description Language
  • the controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer readable medium storing computer readable program code (eg, software or firmware) executable by the (micro)processor. , logic gates, switches, Application Specific Integrated Circuit (ASIC), programmable logic controllers and embedded microcontrollers.
  • controllers include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, For Microchip PIC18F26K20 and Silicone Labs C8051F320, the memory controller can also be implemented as part of the memory's control logic.
  • the controller in addition to implementing the controller in the form of pure computer-readable program code, the controller can be completely programmed with logic gates, switches, application-specific integrated circuits, programmable logic controllers and embedded logic by logically programming the method steps. Microcontroller, etc. to achieve the same function. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be considered as structures within the hardware component. Or even, the means for implementing various functions can be considered as structures within hardware components as well as software modules implementing the methods.
  • 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.
  • 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, or a personal digital assistant. , media player, navigation device, email device, game console, tablet, wearable device, or a combination of any of these devices.
  • the functions are divided into various modules and described separately.
  • the functions of each module can be implemented in the same or multiple software and/or hardware, or the modules that implement the same function can be implemented by a combination of multiple sub-modules or sub-units, etc. .
  • the device embodiments described above are only illustrative.
  • the division of the units is only a logical function division. In actual implementation, there may be other division methods.
  • multiple units or components may be combined or integrated. to another system, or some features can be ignored, or not implemented.
  • the coupling or direct coupling or communication connection between each other shown or discussed may be through some interfaces, and the indirect coupling or communication connection of the devices or units may be in electrical, mechanical or other forms.
  • These computer program instructions may also be stored in a computer-readable memory that causes a computer or other programmable data processing apparatus to operate in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction means, the instructions
  • the device implements the functions specified in a process or processes of the flowchart and/or a block or blocks of the block diagram.
  • These computer program instructions may also be loaded onto a computer or other programmable data processing device, causing a series of operating steps to be performed on the computer or other programmable device to produce computer-implemented processing, thereby executing on the computer or other programmable device.
  • Instructions provide steps for implementing the functions specified in a process or processes of a flowchart diagram and/or a block or blocks of a block diagram.
  • a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
  • processors CPUs
  • input/output interfaces network interfaces
  • memory volatile and non-volatile memory
  • Memory may include non-permanent storage in computer-readable media, random access memory (RAM) and/or non-volatile memory in the form of read-only memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
  • RAM random access memory
  • ROM read-only memory
  • flash RAM flash random access memory
  • Computer-readable media includes both persistent and non-volatile, removable and non-removable media that can be implemented by any method or technology for storage of information.
  • Information may be computer-readable instructions, data structures, modules of programs, 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), and read-only memory.
  • PRAM phase change memory
  • SRAM static random access memory
  • DRAM dynamic random access memory
  • RAM random access memory
  • read-only memory read-only memory
  • ROM read-only memory
  • EEPROM electrically erasable programmable read-only memory
  • flash memory or other memory technology
  • compact disc read-only memory CD-ROM
  • DVD digital versatile disc
  • Magnetic tape magnetic tape storage, graphene storage or other magnetic storage devices or any other non-transmission medium can be used to store information that can be accessed by a computing device.
  • computer-readable media does not include transitory media, such as modulated data signals and carrier waves.
  • one or more embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, one or more embodiments of the present description may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment that combines software and hardware aspects. Furthermore, one or more embodiments of the present description may employ a computer program implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein. Product form.
  • computer-usable storage media including, but not limited to, disk storage, CD-ROM, optical storage, etc.
  • program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types.
  • program modules may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communications network.
  • program modules may be located in both local and remote computer storage media including storage devices.

Landscapes

  • Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Finance (AREA)
  • General Business, Economics & Management (AREA)
  • Computer Security & Cryptography (AREA)
  • Accounting & Taxation (AREA)
  • Marketing (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Computing Systems (AREA)
  • Strategic Management (AREA)
  • Technology Law (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

A consensus method and a blockchain node, wherein the method is executed by means of a first node in a blockchain, the blockchain comprises a plurality of consensus nodes, and the first node is one of the plurality of consensus nodes. The method comprises: acquiring delegation information of a plurality of consensus nodes from a blockchain, wherein the delegation information is used for indicating the number of delegation nodes associated with each consensus node, and the delegation nodes are nodes in the blockchain that delegate any consensus node to perform consensus; and on the basis of the delegation information, performing a consensus operation on a consensus proposal.

Description

一种共识方法和区块链节点A consensus method and blockchain nodes
本申请要求于2022年03月30日提交中国国家知识产权局、申请号为202210325860.7、申请名称为“一种共识方法和区块链节点”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims priority to the Chinese patent application filed with the State Intellectual Property Office of China on March 30, 2022, with application number 202210325860.7 and the application name "A consensus method and blockchain node", the entire content of which is incorporated by reference. in this application.
技术领域Technical field
本说明书实施例属于区块链技术领域,尤其涉及一种共识方法和区块链节点。The embodiments of this specification belong to the field of blockchain technology, and particularly relate to a consensus method and blockchain nodes.
背景技术Background technique
区块链(Blockchain)是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链系统中按照时间顺序将数据区块以顺序相连的方式组合成链式数据结构,并以密码学方式保证的不可篡改和不可伪造的分布式账本。由于区块链具有去中心化、信息不可篡改、自治性等特性,区块链也受到人们越来越多的重视和应用。Blockchain is a new application model of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. In the blockchain system, data blocks are combined into a chained data structure in a chronological manner and are cryptographically guaranteed to be an untamperable and unforgeable distributed ledger. Due to the characteristics of blockchain, such as decentralization, non-tamperable information, and autonomy, blockchain has also received more and more attention and applications.
发明内容Contents of the invention
本发明的目的在于提供一种共识方案,以提高区块链中的共识效率。The purpose of the present invention is to provide a consensus solution to improve the consensus efficiency in the blockchain.
本说明书第一方面提供一种共识方法,由区块链中第一节点执行,所述区块链包括多个共识节点,所述第一节点为所述多个共识节点中的一个,所述方法包括:从区块链中获取委托信息,所述委托信息用于指示各个所述共识节点关联的委托节点的数目,所述委托节点为所述区块链中委托任一所述共识节点进行共识的节点;基于所述委托信息进行对共识提议的共识操作。A first aspect of this specification provides a consensus method, which is executed by a first node in a blockchain. The blockchain includes multiple consensus nodes, and the first node is one of the multiple consensus nodes. The method includes: obtaining entrustment information from the blockchain, the entrustment information is used to indicate the number of entrustment nodes associated with each of the consensus nodes, and the entrustment node is the entrustment of any of the consensus nodes in the blockchain. Consensus node; performs consensus operations on consensus proposals based on the delegation information.
本说明书第二方面提供一种共识节点,包括:获取单元,用于从区块链中获取委托信息,所述委托信息用于指示各个所述共识节点关联的委托节点的数目,所述委托节点为所述区块链中委托任一所述共识节点进行共识的节点;共识单元,用于基于所述委托信息进行对共识提议的共识操作。A second aspect of this specification provides a consensus node, including: an acquisition unit, configured to acquire delegation information from a blockchain, where the delegation information is used to indicate the number of delegation nodes associated with each consensus node, and the delegation node It is a node in the blockchain that entrusts any of the consensus nodes to carry out consensus; a consensus unit is used to perform consensus operations on consensus proposals based on the entrustment information.
本说明书第三方面提供一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算机中执行时,令计算机执行第一方面所述的方法。A third aspect of this specification provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed in a computer, the computer is caused to execute the method described in the first aspect.
本说明书第四方面提供一种共识节点,包括存储器和处理器,所述存储器中存储有可执行代码,所述处理器执行所述可执行代码时,实现第一方面所述的方法。A fourth aspect of this specification provides a consensus node, including a memory and a processor. The memory stores executable code. When the processor executes the executable code, the method described in the first aspect is implemented.
通过本说明书实施例提供的共识方案,通过节点之间的委托,将参与共识的节点减少为较少的数目,减少了共识时间,提高了共识效率,减少了共识通信数据量,降低了成本。Through the consensus scheme provided by the embodiments of this specification, through delegation between nodes, the number of nodes participating in the consensus is reduced to a smaller number, the consensus time is reduced, the consensus efficiency is improved, the amount of consensus communication data is reduced, and the cost is reduced.
附图说明Description of drawings
为了更清楚地说明本说明书实施例的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本说明书中记载的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以 根据这些附图获得其他的附图。In order to explain the technical solutions of the embodiments of this specification more clearly, the drawings needed to be used in the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some of the embodiments recorded in this specification. , for those of ordinary skill in the art, other drawings can also be obtained based on these drawings without exerting creative labor.
图1是一实施例中的区块链架构图;Figure 1 is a blockchain architecture diagram in an embodiment;
图2是一实施例中的PBFT共识算法中的共识过程示意图;Figure 2 is a schematic diagram of the consensus process in the PBFT consensus algorithm in an embodiment;
图3是本说明书一实施例中在区块链中委托节点进行共识的方法流程图;Figure 3 is a flow chart of a method for entrusting nodes to perform consensus in the blockchain in an embodiment of this specification;
图4是本说明书一实施例中的共识方法的流程图;Figure 4 is a flow chart of the consensus method in an embodiment of this specification;
图5是本说明书一实施例中的在区块链中设置恶意节点的方法流程图;Figure 5 is a flow chart of a method for setting up malicious nodes in the blockchain in an embodiment of this specification;
图6为本说明书一实施例中在共识节点出现故障时取消对共识节点的委托的方法流程图;Figure 6 is a flowchart of a method for canceling delegation to a consensus node when a consensus node fails in an embodiment of this specification;
图7是本说明书一实施例中的共识节点的结构图。Figure 7 is a structural diagram of a consensus node in an embodiment of this specification.
具体实施方式Detailed ways
为了使本技术领域的人员更好地理解本说明书中的技术方案,下面将结合本说明书实施例中的附图,对本说明书实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本说明书一部分实施例,而不是全部的实施例。基于本说明书中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都应当属于本说明书保护的范围。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 accompanying drawings in the embodiments of this specification. Obviously, the described The embodiments are only some of the embodiments of this specification, but not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by those of ordinary skill in the art without creative efforts should fall within the scope of protection of this specification.
区块链一般被划分为三种类型:公有链(Public Blockchain),私有链(Private Blockchain)和联盟链(Consortium Blockchain)。此外,还有多种类型的结合,比如私有链+联盟链、联盟链+公有链等不同组合形式。其中去中心化程度最高的是公有链。公有链以比特币、以太坊为代表,加入公有链的参与者可以读取链上的数据记录、参与交易以及通过共识竞争新区块的记账权等。在私有链中,网络的写入权限由某个组织或者机构控制,数据读取权限受组织规定。联盟链是介于公有链以及私有链之间的区块链,可实现“部分去中心化”。联盟链中各个节点通常有与之相对应的实体机构或者组织;参与者通过授权加入网络并组成利益相关联盟,共同维护区块链运行。Blockchains are generally divided into three types: Public Blockchain, Private Blockchain and Consortium Blockchain. In addition, there are many types of combinations, such as private chain + alliance chain, alliance chain + public chain and other different combinations. Among them, the most decentralized one is the public chain. Public chains are represented by Bitcoin and Ethereum. Participants who join the public chain can read data records on the chain, participate in transactions, and compete for the accounting rights of new blocks through consensus. In a private chain, the writing permission of the network is controlled by an organization or institution, and the data reading permission is regulated by the organization. The alliance chain is a blockchain between the public chain and the private chain, which can achieve "partial decentralization". Each node in the alliance chain usually has a corresponding entity or organization; participants join the network through authorization and form a stakeholder alliance to jointly maintain the operation of the blockchain.
图1示出了一实施例中的区块链架构图。在图1所示的区块链架构图中,区块链100中例如包含节点1-节点7共7个节点。节点之间的连线示意性的表示P2P(Peer to Peer,点对点)连接。这些节点上可存储全量的账本,即存储全部区块和全部账户的状态。其中,区块链中的每个节点可通过执行相同的交易而产生区块链中的相同的状态,区块链中的每个节点可存储相同的状态数据库。可以理解,图1中虽然示出了区块链中包括7个节点,本说明书实施例不限于此,而是可以包括其他数目的节点。具体是,区块链中包含的节点可以满足拜占庭容错(Byzantine Fault Tolerance,BFT)要求。所述的拜占庭容错要求可以理解为在区块链内部可以存在拜占庭节点,而区块链对外不体现拜占庭行为。一般的,一些拜占庭容错算法中要求节点个数大于3f+1,f为拜占庭节点(即恶意节点)个数,例如实用拜占庭容错算法PBFT(Practical Byzantine Fault Tolerance)。Figure 1 shows a blockchain architecture diagram in an embodiment. In the blockchain architecture diagram shown in Figure 1, the blockchain 100 includes, for example, a total of 7 nodes from node 1 to node 7. The connections between nodes schematically represent P2P (Peer to Peer, point-to-point) connections. These nodes can store the entire ledger, that is, store the status of all blocks and all accounts. Among them, each node in the blockchain can generate the same state in the blockchain by executing the same transaction, and each node in the blockchain can store the same state database. It can be understood that although FIG. 1 shows that the blockchain includes 7 nodes, the embodiments of this description are not limited to this, and may include other numbers of nodes. Specifically, the nodes included in the blockchain can meet Byzantine Fault Tolerance (BFT) requirements. The mentioned Byzantine fault tolerance requirements can be understood as meaning that Byzantine nodes can exist within the blockchain, but the blockchain does not reflect Byzantine behavior externally. Generally, some Byzantine fault-tolerant algorithms require the number of nodes to be greater than 3f+1, where f is the number of Byzantine nodes (i.e. malicious nodes), such as the Practical Byzantine Fault Tolerance algorithm PBFT (Practical Byzantine Fault Tolerance).
区块链领域中的交易可以指在区块链中执行并记录在区块链中的任务单元。交易中通常包括发送字段(From)、接收字段(To)和数据字段(Data)。其中,在交易为转账交易的情况中,From字段表示发起该交易(即发起对另一个账户的转账任务)的账户地址,To字段表示接收该交易(即接收转账)的账户地址,Data字段中包括转 账金额。在交易调用区块链中的智能合约的情况中,From字段表示发起该交易的账户地址,To字段表示交易所调用的合约的账户地址,Data字段中包括调用合约中的函数名、及对该函数的传入参数等数据,以用于在交易执行时从区块链中获取该函数的代码并执行该函数的代码。Transactions in the blockchain field can refer to task units that are executed and recorded in the blockchain. Transactions usually include sending fields (From), receiving fields (To) and data fields (Data). Among them, when the transaction is a transfer transaction, the From field represents the account address that initiated the transaction (that is, initiated a transfer task to another account), the To field represents the account address that received the transaction (that is, received the transfer), and the Data field Include transfer amount. In the case of a transaction calling a smart contract in the blockchain, the From field indicates the account address that initiated the transaction, the To field indicates the account address of the contract called by the exchange, and the Data field includes the function name in the calling contract and the corresponding Data such as the incoming parameters of the function are used to obtain the code of the function from the blockchain and execute the code of the function when the transaction is executed.
区块链中可提供智能合约的功能。区块链上的智能合约是在区块链系统上可以被交易触发执行的合约。智能合约可以通过代码的形式定义。在区块链中调用智能合约,是发起一笔指向智能合约地址的交易,使得区块链中每个节点分布式地运行智能合约代码。需要说明的是,除了可以由用户创建智能合约,也可以在创世块中由系统设置智能合约。这类合约一般称为创世合约。一般的,创世合约中可以设置一些区块链的数据结构、参数、属性和方法。此外,具有系统管理员权限的账户可以创建系统级的合约,或者修改系统级的合约(简称为系统合约)。其中,所述系统合约可用于在区块链中增加不同业务的数据的数据结构。The functions of smart contracts can be provided in the blockchain. Smart contracts on the blockchain are contracts that can be triggered and executed by transactions on the blockchain system. Smart contracts can be defined in the form of code. Calling a smart contract in the blockchain is to initiate a transaction pointing to the smart contract address, allowing each node in the blockchain to run the smart contract code in a distributed manner. It should be noted that in addition to smart contracts that can be created by users, smart contracts can also be set by the system in the genesis block. This type of contract is generally called a creation contract. Generally, some blockchain data structures, parameters, properties and methods can be set in the genesis contract. In addition, accounts with system administrator rights can create system-level contracts or modify system-level contracts (referred to as system contracts). Among them, the system contract can be used to add data structures for different business data in the blockchain.
在部署合约的场景中,例如,Bob将一个包含创建智能合约信息(即部署合约)的交易发送到如图1所示的区块链中,该交易的data字段包括待创建的合约的代码(如字节码或者机器码),交易的to字段为空,以表示该交易用于部署合约。节点间通过共识机制达成一致后,确定合约的合约地址“0x6f8ae93…”,各个节点在状态数据库中添加与该智能合约的合约地址对应的合约账户,分配与该合约账户对应的状态存储,并将合约代码保存在该合约的状态存储中,从而合约创建成功。In the scenario of deploying a contract, for example, Bob sends a transaction containing information about creating a smart contract (i.e., deploying the contract) to the blockchain as shown in Figure 1. The data field of the transaction includes the code of the contract to be created ( Such as bytecode or machine code), the to field of the transaction is empty to indicate that the transaction is used to deploy the contract. After the nodes reach an agreement through the consensus mechanism, the contract address "0x6f8ae93..." of the contract is determined. Each node adds the contract account corresponding to the contract address of the smart contract in the state database, allocates the state storage corresponding to the contract account, and stores The contract code is saved in the state storage of the contract, so the contract is created successfully.
在调用合约的场景中,例如,Bob将一个用于调用智能合约的交易发送到如图1所示的区块链中,该交易的from字段是交易发起方(即Bob)的账户的地址,to字段中的“0x6f8ae93…”代表了被调用的智能合约的地址,交易的data字段包括调用智能合约的方法和参数。在区块链中对该交易进行共识之后,区块链中的各个节点可分别执行该交易,从而分别执行该合约,基于该合约的执行更新状态数据库。In the scenario of calling a contract, for example, Bob sends a transaction for calling a smart contract to the blockchain as shown in Figure 1. The from field of the transaction is the address of the account of the transaction initiator (Bob). "0x6f8ae93..." in the to field represents the address of the smart contract being called, and the data field of the transaction includes the method and parameters for calling the smart contract. After consensus is reached on the transaction in the blockchain, each node in the blockchain can execute the transaction respectively, thereby executing the contract respectively, and update the status database based on the execution of the contract.
区块链技术区别于传统技术的去中心化特点之一,就是在各个节点上进行记账,或者称为分布式记账,而不是传统的集中式记账。区块链系统要成为一个难以攻破的、公开的、不可篡改数据记录的去中心化诚实可信系统,需要在尽可能短的时间内做到分布式数据记录的安全、明确及不可逆。不同类型的区块链网络中,为了在各个记录账本的节点中保持账本的一致,通常采用共识算法来保证,即前述提到的共识机制。例如,区块链节点之间可以实现区块粒度的共识机制,比如在节点(例如某个独特的节点)产生一个区块后,如果产生的这个区块得到其它节点的认可,其它节点记录相同的区块。再例如,区块链节点之间可以实现交易粒度的共识机制,比如在节点(例如某个独特的节点)获取一笔区块链交易后,如果这笔区块链交易得到其他节点的认可,认可该区块链交易的各个节点可以分别将该区块链交易添加至自身维护的最新区块中,并且最终能够确保各个节点产生相同的最新区块。共识机制是区块链节点就区块信息(或称区块数据)达成全网一致共识的机制,可以保证最新区块被准确添加至区块链。当前主流的共识机制包括:工作量证明(Proof of Work,POW)、股权证明(Proof of Stake,POS)、委任权益证明(Delegated Proof of Stake,DPOS)、实用拜占庭容错(Practical Byzantine Fault Tolerance,PBFT)算法等。其中,在各种共识算法中,通常在预设数目的节点对待共识的数据(即共识提议)达成一致之后,从而确 定对该共识提议的共识成功。具体是,在PBFT算法中,对于N≥3f+1个共识节点,可容忍f个恶意节点,也就是说,当N个共识节点中2f+1个节点达成一致时,可确定共识成功。One of the decentralized features of blockchain technology that distinguishes it from traditional technology is that accounting is performed on each node, or distributed accounting, instead of traditional centralized accounting. In order for the blockchain system to become a decentralized, honest and trustworthy system that is hard to break, open, and cannot tamper with data records, it needs to make distributed data records secure, clear, and irreversible in the shortest possible time. In different types of blockchain networks, in order to maintain the consistency of the ledger in each node that records the ledger, a consensus algorithm is usually used to ensure it, that is, the consensus mechanism mentioned above. For example, blockchain nodes can implement a block-granular consensus mechanism. For example, after a node (such as a unique node) generates a block, if the generated block is recognized by other nodes, the records of other nodes will be the same. block. For another example, a transaction-granularity consensus mechanism can be implemented between blockchain nodes. For example, after a node (such as a unique node) obtains a blockchain transaction, if the blockchain transaction is recognized by other nodes, Each node that recognizes the blockchain transaction can add the blockchain transaction to the latest block maintained by itself, and ultimately ensure that each node generates the same latest block. The consensus mechanism is a mechanism for blockchain nodes to reach a consensus across the entire network on block information (or block data), which can ensure that the latest blocks are accurately added to the blockchain. The current mainstream consensus mechanisms include: Proof of Work (POW), Proof of Stake (POS), Delegated Proof of Stake (DPOS), Practical Byzantine Fault Tolerance (PBFT) ) algorithm, etc. Among them, in various consensus algorithms, the success of the consensus on the consensus proposal is usually determined after a preset number of nodes reach an agreement on the consensus data (ie, consensus proposal). Specifically, in the PBFT algorithm, for N ≥ 3f + 1 consensus nodes, f malicious nodes can be tolerated. That is to say, when 2f + 1 nodes among the N consensus nodes reach an agreement, the consensus can be determined to be successful.
图2为PBFT共识算法中的共识过程示意图。如图2所示,根据PBFT共识算法,可将共识过程划分为请求(Request)、预备(Pre-Prepare)、准备(Prepare)和提交(Commit)四个阶段。假设一区块链中包括节点n1-节点n4四个共识节点,其中,节点n1例如为主节点,节点n2-节点n4例如为从节点,根据PBFT算法,在节点n1-节点n4中可容忍f=1个恶意节点。具体是,在请求阶段,区块链的用户可通过其用户设备向节点n1发送请求,该请求例如为区块链交易的形式。在预备阶段,节点n1在从一个或多个用户设备接收到多个交易之后,可将该多个交易打包为共识提议,将该共识提议及节点n1对该共识提议的签名发送给其他共识节点(即节点n2-节点n4),以用于生成区块,该共识提议中可包括该多个交易的交易体和该多个交易的提交顺序等信息。在准备阶段,各个从节点可对共识提议进行签名并发送给其他各个节点。假设节点n4为恶意节点,节点n1、节点n2和节点n3在分别接收到2f=2个其他共识节点的对共识提议的签名之后,可确定准备阶段完成,可进入提交阶段。例如,如图2中所示,节点n1在接收到节点n2和节点n3的签名之后,验证节点n2和节点n3的签名都是正确的对共识提议的签名,则确定准备阶段完成,节点n2在接收到节点n3的签名和预备阶段节点n1的签名并验证通过之后,确定准备阶段完成。在提交阶段,各个共识节点对共识提议进行提交阶段的签名并发送给其他各个共识节点,各个共识节点在接收到2f=2个其他共识节点的提交阶段的签名之后,可确定提交阶段完成,共识成功。例如,节点n1在接收到节点n2和节点n3的提交阶段的签名并验证之后,确定提交阶段完成,从而,节点n1可执行根据共识提议执行所述多个交易,生成并存储包括所述多个交易的区块(例如区块B1),根据多个交易的执行结果更新世界状态,并将多个交易的执行结果返回给用户设备。类似地,节点n2和节点n3在确定提交阶段完成之后,执行所述多个交易,生成并存储区块B1,并根据多个交易的执行结果更新世界状态。通过上述过程,实现了节点n1、节点n2和节点n3的存储一致性。也就是说,节点n1-节点n4在存在一个恶意节点的情况下仍可以实现对共识提议的共识成功,完成对区块的执行。Figure 2 is a schematic diagram of the consensus process in the PBFT consensus algorithm. As shown in Figure 2, according to the PBFT consensus algorithm, the consensus process can be divided into four stages: Request, Pre-Prepare, Prepare and Commit. Assume that a blockchain includes four consensus nodes, node n1 - node n4, where node n1 is, for example, the master node, and node n2 - node n4, for example, are slave nodes. According to the PBFT algorithm, f can be tolerated in node n1 - node n4. =1 malicious node. Specifically, in the request phase, the user of the blockchain can send a request to the node n1 through its user device, and the request is, for example, in the form of a blockchain transaction. In the preliminary stage, after receiving multiple transactions from one or more user devices, node n1 can package the multiple transactions into a consensus proposal, and send the consensus proposal and node n1's signature to the consensus proposal to other consensus nodes. (i.e., node n2 - node n4) to generate blocks. The consensus proposal may include information such as the transaction body of the multiple transactions and the submission order of the multiple transactions. During the preparation phase, each slave node can sign the consensus proposal and send it to each other node. Assuming that node n4 is a malicious node, node n1, node n2 and node n3 can determine that the preparation phase is completed and can enter the submission phase after receiving the signatures of 2f = 2 other consensus nodes on the consensus proposal. For example, as shown in Figure 2, after node n1 receives the signatures of node n2 and node n3, it verifies that the signatures of node n2 and node n3 are correct signatures of the consensus proposal, then it is determined that the preparation phase is completed, and node n2 is After receiving the signature of node n3 and the signature of node n1 in the preparation phase and passing the verification, it is determined that the preparation phase is completed. In the submission phase, each consensus node signs the consensus proposal in the submission phase and sends it to each other consensus node. After receiving the signatures of 2f = 2 other consensus nodes in the submission phase, each consensus node can confirm that the submission phase is completed and the consensus success. For example, after receiving and verifying the signatures of the submission phase of node n2 and node n3, node n1 determines that the submission phase is completed. Therefore, node n1 can execute the multiple transactions according to the consensus proposal, generate and store the multiple transactions including the multiple transactions. The transaction block (for example, block B1) updates the world state based on the execution results of multiple transactions and returns the execution results of multiple transactions to the user device. Similarly, after determining that the submission phase is completed, node n2 and node n3 execute the multiple transactions, generate and store block B1, and update the world state according to the execution results of the multiple transactions. Through the above process, the storage consistency of node n1, node n2 and node n3 is achieved. In other words, nodes n1-node n4 can still achieve successful consensus on the consensus proposal and complete the execution of the block even if there is a malicious node.
近年来,区块链的规模越来越大,业务也越来越复杂。随着节点规模的增大,通过图2所示的过程在多个共识节点之间进行共识,将需要多个共识节点之间进行多次通信,使得共识效率下降。例如,在图1所示的区块链中,节点数为7个,在该7个节点都参与共识的情况中,可容忍的恶意节点数f为2个。在共识过程中的准备阶段或者提交阶段,每个节点在接收到2f=4个其他节点对共识提议的签名并验证通过之后才能确认该阶段完成。In recent years, the scale of blockchain has become larger and larger, and the business has become more and more complex. As the size of the node increases, consensus among multiple consensus nodes through the process shown in Figure 2 will require multiple communications between multiple consensus nodes, causing the consensus efficiency to decrease. For example, in the blockchain shown in Figure 1, the number of nodes is 7. In the case where all 7 nodes participate in the consensus, the number f of malicious nodes that can be tolerated is 2. In the preparation phase or submission phase of the consensus process, each node can only confirm the completion of this phase after receiving and verifying the signatures of 2f = 4 other nodes on the consensus proposal.
在一种相关技术中,由多个节点投票选举出预设数目的共识节点。该相关技术通常在公链上运行,并基于如下三个关键要素:1)激励机制:通过发行的虚拟代币,股权,利息等等奖励,激励节点参与到竞选和投票中;2)权益质押:通过足够高的权益质押,提升做恶成本,让选出来的代表节点,不会去做恶,保证了系统的安全性;3)链下治理:通过链下的基金会,仲裁会的治理,提升代币的价值,保证系统的良性运 转。然而,由于在联盟链中通常不包括以上这些要素,因此,上述共识机制无法在联盟链中使用。In a related technology, multiple nodes vote to elect a preset number of consensus nodes. This related technology usually runs on the public chain and is based on the following three key elements: 1) Incentive mechanism: through the issuance of virtual tokens, equity, interest and other rewards, nodes are encouraged to participate in elections and voting; 2) Equity pledge : Through high enough equity pledge, the cost of doing evil is increased, so that the elected representative nodes will not do evil, ensuring the security of the system; 3) Off-chain governance: through the governance of off-chain foundations and arbitration committees , enhance the value of tokens and ensure the healthy operation of the system. However, since the above elements are usually not included in the alliance chain, the above consensus mechanism cannot be used in the alliance chain.
为此,本说明书实施例提出一种通过委托机制收敛共识节点规模的方案,该方案能合理利用实际项目中节点间的一些信任关系,支持大规模节点的稳定共识。To this end, the embodiment of this specification proposes a solution for converging the scale of consensus nodes through a delegation mechanism. This solution can reasonably utilize some trust relationships between nodes in actual projects and support stable consensus of large-scale nodes.
图3为本说明书一实施例中在区块链中委托节点进行共识的方法流程图。Figure 3 is a flow chart of a method for entrusting nodes to perform consensus in the blockchain in an embodiment of this specification.
如图3所示,首先在步骤S301,节点5向区块链发送交易Tx1,用于委托节点2进行共识。As shown in Figure 3, first in step S301, node 5 sends transaction Tx1 to the blockchain to entrust node 2 to carry out consensus.
假设图1中的节点5将节点2视为可信节点,节点5可向区块链中发送用于进行委托的交易Tx1,以委托节点2代表节点5进行共识。其中,节点5与节点2例如可以为同一机构中的两个节点。具体是,节点5可生成交易Tx1,该交易Tx1可用于调用区块链中预先部署的智能合约C1,以用于在区块链中记录委托信息。节点5在生成交易Tx1之后,可将交易Tx1发送给区块链中的任一节点(例如节点1),以通过图2所示的过程在区块链中共识并执行。Assuming that node 5 in Figure 1 regards node 2 as a trusted node, node 5 can send a transaction Tx1 for delegation to the blockchain, entrusting node 2 to perform consensus on behalf of node 5. Node 5 and node 2 may be, for example, two nodes in the same organization. Specifically, node 5 can generate transaction Tx1, which can be used to call the pre-deployed smart contract C1 in the blockchain to record delegation information in the blockchain. After generating transaction Tx1, node 5 can send transaction Tx1 to any node in the blockchain (for example, node 1) to achieve consensus and execution in the blockchain through the process shown in Figure 2.
在步骤S303,区块链中的节点执行交易Tx1,在区块链中记录委托信息。In step S303, the node in the blockchain executes the transaction Tx1 and records the delegation information in the blockchain.
假设,如图1所示,区块链中节点1-节点7当前都是共识节点,区块链中的各个共识节点在对交易Tx1所在的区块(例如区块B1)对应的共识提议共识成功之后,分别执行交易Tx1,并根据交易Tx1的执行结果更新世界状态。以节点1为例,节点1在执行交易Tx1之后,可在合约C1的合约状态中记录该委托信息。Assume that, as shown in Figure 1, nodes 1 to 7 in the blockchain are currently consensus nodes. Each consensus node in the blockchain is proposing consensus on the consensus corresponding to the block where transaction Tx1 is located (for example, block B1). After success, transaction Tx1 is executed respectively, and the world state is updated based on the execution result of transaction Tx1. Taking node 1 as an example, after executing transaction Tx1, node 1 can record the commission information in the contract status of contract C1.
在一种实施方式中,合约C1的合约状态中可存储有共识节点信息表,在执行交易Tx1之前,该共识节点信息表例如如表1所示:In one implementation, a consensus node information table may be stored in the contract state of contract C1. Before executing transaction Tx1, the consensus node information table is, for example, as shown in Table 1:
表1Table 1
共识节点Consensus node 权重Weights 委托节点Delegate node
节点1Node 1 11  
节点2Node 2 11  
节点3Node 3 11  
节点4Node 4 11  
节点5Node 5 11  
节点6Node 6 11  
节点7Node 7 11  
表1示出节点1-节点7都是共识节点,其委托节点一栏都为空,表示当前还没有其他节点委托其代为进行共识,权重为1表示各个共识节点当前仅代表自身进行共识。Table 1 shows that nodes 1 to 7 are all consensus nodes, and their entrusted node columns are all empty, indicating that no other node has entrusted them to perform consensus on their behalf. A weight of 1 indicates that each consensus node currently only performs consensus on its own behalf.
节点1在执行完成交易Tx1并根据交易Tx1更新合约C1的合约状态之后,根据该交易Tx1,由于节点5委托节点2进行委托,因此,节点5不再进行共识,因此在共识节点信息表中删除节点5的信息,并更改节点2的信息,在进行该修改之后,共识节点信息表如表2所示:After node 1 executes transaction Tx1 and updates the contract status of contract C1 according to transaction Tx1, according to this transaction Tx1, since node 5 entrusts node 2 to entrust, node 5 no longer performs consensus, so it is deleted from the consensus node information table The information of node 5 and change the information of node 2. After making this modification, the consensus node information table is as shown in Table 2:
表2Table 2
共识节点Consensus node 权重Weights 委托节点Delegate node
节点1Node 1 11  
节点2Node 2 22 节点5Node 5
节点3Node 3 11  
节点4Node 4 11  
节点6Node 6 11  
节点7Node 7 11  
类似地,假设节点6向区块链发送交易Tx2,以用于委托节点2进行共识,节点7向区块链发送交易Tx3,以用于委托节点3进行共识,区块链中通过顺序执行交易Tx2和交易Tx3可得到如表3所示的共识节点信息表:Similarly, assume that node 6 sends transaction Tx2 to the blockchain to entrust node 2 for consensus, and node 7 sends transaction Tx3 to the blockchain to entrust node 3 for consensus. The transactions are executed sequentially in the blockchain. Tx2 and transaction Tx3 can obtain the consensus node information table shown in Table 3:
表3table 3
共识节点Consensus node 权重Weights 委托节点Delegate node
节点1Node 1 11  
节点2Node 2 33 节点5、节点6Node 5, Node 6
节点3Node 3 22 节点7Node 7
节点4Node 4 11  
在通过如上所述过程进行委托之后,将区块链中的共识节点的数目从7个减少为4个,从而可大大减少区块链共识过程中的通信量。节点1-节点4在进行共识时,可基于权重来计算签名数目,从而代表委托节点进行共识。After delegation through the process described above, the number of consensus nodes in the blockchain is reduced from 7 to 4, which can greatly reduce the communication volume in the blockchain consensus process. When performing consensus, Node 1-Node 4 can calculate the number of signatures based on the weight, thereby performing consensus on behalf of the entrusted node.
在另一实施方式中,合约C1的合约状态中还包括委托节点信息表,该委托节点信息表中例如包括委托其他节点进行共识的节点的标识和对应的受托节点的标识。区块链中的节点在执行各个用于委托节点的交易之后,还在合约C1的合约状态中更新该委托节点信息表。例如,In another embodiment, the contract status of contract C1 also includes a delegation node information table. The delegation node information table includes, for example, the identification of the node that entrusts other nodes to perform consensus and the identification of the corresponding trusted node. After executing each transaction for the entrusted node, the node in the blockchain also updates the entrusted node information table in the contract status of contract C1. For example,
节点1在执行上述交易Tx3之后,可生成如表4所示的委托节点信息表:After node 1 executes the above transaction Tx3, it can generate the entrusted node information table as shown in Table 4:
表4Table 4
委托节点Delegate node 受托节点Trusted node
节点5Node 5 节点2Node 2
节点6Node 6 节点2Node 2
节点7Node 7 节点3Node 3
可以理解,本说明书实施例中,在区块链中记录的委托信息不限于如上文所述,只要该委托信息可指示各个共识节点对应的委托节点数目,便可以执行本说明书实施例提供的共识方法。It can be understood that in the embodiments of this specification, the delegation information recorded in the blockchain is not limited to the above. As long as the delegation information can indicate the number of delegation nodes corresponding to each consensus node, the consensus provided by the embodiments of this specification can be executed. method.
图4为本说明书一实施例中的共识方法的流程图。该共识方法可由区块链中的任一共识节点执行,具体是包括如下步骤:Figure 4 is a flow chart of a consensus method in an embodiment of this specification. This consensus method can be executed by any consensus node in the blockchain, specifically including the following steps:
步骤S401,从区块链中获取委托信息;Step S401, obtain delegation information from the blockchain;
步骤S403,基于委托信息进行共识操作。Step S403: Perform consensus operation based on delegation information.
下文将详细描述图4所示方法的各个步骤。Each step of the method shown in Figure 4 will be described in detail below.
首先,在步骤S401,各个共识节点获取区块链中的委托信息。First, in step S401, each consensus node obtains the delegation information in the blockchain.
下文中以节点1为例描述图4所示方法。所述委托信息例如包括节点1中合约C1的合约状态的如表3所示的共识节点信息表。假设节点1为多个共识节点中的主节点,参考图2,在请求阶段,节点1在从一个或多个用户设备接收到多个交易之后,生成共识提议,该共识提议中例如包括将生成的区块B2中的多个交易及该多个交易的提 交顺序。为了与区块链中的共识节点进行共识,节点1需要获取区块链中的各个共识节点的信息。因此,节点1可从区块链中读取如表3所示的共识节点信息表。具体是,节点1可发起用于调用合约C1的查询请求(或者查询交易),从而从本地查询到合约C1当前的共识节点信息表。The method shown in Figure 4 is described below taking node 1 as an example. The delegation information includes, for example, the consensus node information table shown in Table 3 of the contract status of contract C1 in node 1. Assume that node 1 is the master node among multiple consensus nodes. Referring to Figure 2, in the request phase, node 1 generates a consensus proposal after receiving multiple transactions from one or more user devices. The consensus proposal includes, for example, the generation Multiple transactions in block B2 and the submission order of the multiple transactions. In order to reach consensus with the consensus nodes in the blockchain, Node 1 needs to obtain the information of each consensus node in the blockchain. Therefore, node 1 can read the consensus node information table shown in Table 3 from the blockchain. Specifically, node 1 can initiate a query request (or query transaction) for calling contract C1, thereby querying the current consensus node information table of contract C1 locally.
在步骤S403,各个共识节点基于委托信息进行共识操作。In step S403, each consensus node performs a consensus operation based on the delegation information.
具体是,在预备阶段,节点1基于表3中的各个共识节点的标识,将共识提议及节点1对该共识提议的签名分别发送给节点2、节点3和节点4。Specifically, in the preliminary stage, node 1 sends the consensus proposal and node 1's signature of the consensus proposal to node 2, node 3 and node 4 respectively based on the identification of each consensus node in Table 3.
在准备阶段,节点2、节点3和节点4分别对共识提议签名,并将共识提议及其签名分别发送给其他共识节点。例如,节点1接收到节点2和节点3对共识提议的签名,节点1可根据共识节点信息表中节点1、节点2和节点3的权重计算所获取的签名数S1,即S1=1+3+2=6。如上文所述,在图1所示的区块链中,可容忍f=2个恶意节点,因此,每个共识节点需要获取2f+1=5个共识节点的签名,才可以确认预备阶段完成。节点1在如上所述计算签名数S1=6>5,因此可确认预备阶段完成。In the preparation phase, node 2, node 3 and node 4 respectively sign the consensus proposal and send the consensus proposal and its signature to other consensus nodes respectively. For example, node 1 receives the signatures of node 2 and node 3 on the consensus proposal. Node 1 can calculate the number of signatures S1 obtained based on the weights of node 1, node 2 and node 3 in the consensus node information table, that is, S1=1+3 +2=6. As mentioned above, in the blockchain shown in Figure 1, f = 2 malicious nodes can be tolerated. Therefore, each consensus node needs to obtain the signatures of 2f + 1 = 5 consensus nodes to confirm that the preliminary phase is completed. . Node 1 calculates the signature number S1=6>5 as described above, so it can confirm that the preliminary phase is completed.
节点2在接收到节点1和节点3对共识提议的签名之后,可根据表3中节点1、节点2和节点3的权重计算获取的签名数S2=1+3+2=6>5,因此可确认预备阶段完成。After receiving the signatures of node 1 and node 3 on the consensus proposal, node 2 can calculate the number of signatures obtained based on the weights of node 1, node 2 and node 3 in Table 3 S2=1+3+2=6>5, therefore It can be confirmed that the preliminary stage is completed.
节点3和节点4可类似地确定预备阶段完成。Node 3 and Node 4 may similarly determine that the preliminary phase is complete.
在预备阶段完成之后,节点1-节点4分别将准备阶段的对共识提议的签名发送给表3中的其他共识节点。各个共识节点可类似地根据表3确定所获取的签名数,在签名数大于或者等于5的情况下,可确定准备阶段完成,因此完成对区块B2的共识过程。After the preparation phase is completed, Node 1-Node 4 respectively send the signatures of the consensus proposal in the preparation phase to other consensus nodes in Table 3. Each consensus node can similarly determine the number of signatures obtained according to Table 3. When the number of signatures is greater than or equal to 5, it can be determined that the preparation phase is completed, and therefore the consensus process for block B2 is completed.
节点1-在节点4在完成对区块B2的共识之后分别执行区块B2中的多个交易,生成区块B2,并根据区块B2的执行结果更新世界状态。之后,节点1-节点4可分别将生成的区块B2发送给各自的委托节点。具体是,节点2可将其生成的区块B2发送给节点5和节点6,节点3可将其生成的区块B2发送给节点7。各个委托节点在接收到区块B2之后,存储区块B2,并通过执行区块B2中包括的多个交易更新世界状态,从而达到与共识节点一致的世界状态。Node 1 - After completing the consensus on block B2, node 4 executes multiple transactions in block B2, generates block B2, and updates the world state based on the execution results of block B2. Afterwards, Node 1-Node 4 can respectively send the generated block B2 to their respective entrusting nodes. Specifically, node 2 can send the block B2 it generates to node 5 and node 6, and node 3 can send the block B2 it generates to node 7. After receiving block B2, each delegation node stores block B2 and updates the world state by executing multiple transactions included in block B2, thereby achieving a world state consistent with the consensus node.
在另一种实施方式中,各个共识节点在生成区块B2之后可向区块链各节点广播区块同步事件。委托节点收到事件后,从其委托的共识节点同步区块B2。在另一种实施方式中,委托节点可定时向其委托的共识节点发送查询请求,以查询共识节点的块高,在发现共识节点的块高高于自身的块高时,从其委托的共识节点同步新的区块。In another implementation, each consensus node may broadcast a block synchronization event to each node of the blockchain after generating block B2. After the delegated node receives the event, it synchronizes block B2 from its delegated consensus node. In another implementation, the entrusting node can periodically send query requests to the consensus node it entrusts to query the block height of the consensus node. When it is found that the block height of the consensus node is higher than its own block height, the entrusted consensus node can Nodes synchronize new blocks.
各个共识节点在进行共识的过程中,可在日志中记录所接收到的各个签名的来源节点的标识等信息,从而在接收到共识提议出现分叉(即接收到不同的共识提议及其签名)的情况中,可根据日志锁定共识节点中的恶意节点。共识节点在确定出恶意节点之后,可通过在区块链记录该恶意节点及其委托节点,以限制其参与共识。During the consensus process, each consensus node can record information such as the identity of the source node of each received signature in the log, so that a fork occurs when a consensus proposal is received (that is, different consensus proposals and their signatures are received) In this case, the malicious nodes among the consensus nodes can be locked based on the logs. After the consensus node identifies a malicious node, it can limit its participation in the consensus by recording the malicious node and its delegated nodes in the blockchain.
图5为本说明书一实施例中的在区块链中设置恶意节点的方法流程图。Figure 5 is a flow chart of a method for setting up malicious nodes in the blockchain according to an embodiment of this specification.
如图5所示,假设节点4在共识的过程中确定节点3为恶意节点,节点4通过查询上述智能合约的合约状态,可确定节点3的权重为2,即为上述区块链可容忍的恶意节点数目,因此,该区块链中可通过共识将节点3设置为恶意节点。As shown in Figure 5, assume that node 4 determines that node 3 is a malicious node during the consensus process. By querying the contract status of the above-mentioned smart contract, node 4 can determine that the weight of node 3 is 2, which is what the above-mentioned blockchain can tolerate. The number of malicious nodes, therefore, node 3 can be set as a malicious node through consensus in this blockchain.
具体是,在步骤S501,节点4向节点1发送交易Tx4,交易Tx4可用于调用上述 智能合约,用于在区块链中将节点3设置为恶意节点。Specifically, in step S501, node 4 sends transaction Tx4 to node 1. Transaction Tx4 can be used to call the above smart contract to set node 3 as a malicious node in the blockchain.
在步骤S503,区块链中的共识节点执行交易Tx4,在区块链中更新委托信息。In step S503, the consensus node in the blockchain executes transaction Tx4 and updates the delegation information in the blockchain.
区块链中当前的共识节点(节点1-节点4)在接收到对包括交易Tx4的区块B3的共识提议之后,通过图2所示过程对该共识提议进行共识,由于各个共识节点的权重之和(7)与恶意节点(节点3)权重2满足3f+1:f的关系,因此节点1-节点3可对该共识提议共识成功。以节点1为例,节点1在对区块B3的共识提议共识成功之后,执行交易Tx4,在合约C1的合约状态中,在表3中删除节点3的信息,在表4中删除节点7的信息,并将节点3和节点7放入合约状态中的恶意节点列表中,当将节点3和节点7加入恶意节点列表之后,节点3和节点7都不能再参与共识,而仅能从任一共识节点同步区块。After receiving the consensus proposal for block B3 including transaction Tx4, the current consensus nodes (node 1-node 4) in the blockchain consensus on the consensus proposal through the process shown in Figure 2. Due to the weight of each consensus node The sum (7) and the weight 2 of the malicious node (node 3) satisfy the relationship of 3f+1:f, so nodes 1-node 3 can successfully propose a consensus for this consensus. Take node 1 as an example. After the consensus proposal for block B3 succeeds, node 1 executes transaction Tx4. In the contract status of contract C1, the information of node 3 is deleted in Table 3, and the information of node 7 is deleted in Table 4. information, and put node 3 and node 7 into the malicious node list in the contract state. After adding node 3 and node 7 to the malicious node list, node 3 and node 7 can no longer participate in the consensus, but can only participate in the consensus from either Consensus nodes synchronize blocks.
可以理解,在共识节点确定节点2为恶意节点的情况中,由于节点2的权重为3,与各个共识节点的权重之和(7)不能满足小于或者等于f:3f+1的关系,因此不能通过执行交易将节点2设置为恶意节点。It can be understood that in the case where the consensus node determines that node 2 is a malicious node, since the weight of node 2 is 3, the sum of the weights of each consensus node (7) cannot satisfy the relationship of less than or equal to f: 3f+1, so it cannot Set node 2 as a malicious node by executing the transaction.
另外,共识节点可以相互监测运行状态,或者委托节点在委托共识节点之后可以监测其委托的共识节点的状态,在监测到共识节点出现故障时,可向区块链发送交易,以用于取消委托节点对共识节点的委托。In addition, the consensus nodes can monitor each other's operating status, or the entrusting node can monitor the status of the entrusted consensus node after entrusting the consensus node. When a failure of the consensus node is detected, a transaction can be sent to the blockchain to cancel the entrustment. Delegation of nodes to consensus nodes.
图6为本说明书一实施例中在共识节点出现故障时取消对共识节点的委托的方法流程图。Figure 6 is a flowchart of a method for canceling delegation to a consensus node when a consensus node fails in an embodiment of this specification.
如图6所示,假设节点4确定节点3出现故障,在步骤S601,节点4可向节点1发送调用上述合约C1的交易Tx5,以用于取消委托节点(即节点7)对节点3的委托。As shown in Figure 6, assuming that node 4 determines that node 3 is faulty, in step S601, node 4 can send a transaction Tx5 that calls the above contract C1 to node 1 to cancel the entrustment of node 3 by the entrusting node (ie node 7). .
在步骤S603,节点1执行交易Tx5,更新委托信息。In step S603, node 1 executes transaction Tx5 and updates the delegation information.
假设区块链中的当前共识节点如表3所示,如上文所述,由于节点3的权重与全部共识节点的权重和满足f:3f+1的关系,因此,节点1、节点2和节点4可对交易Tx5共识成功,并根据交易Tx5更新委托信息。具体是,以节点1为例,节点1在执行交易Tx5并共识成功之后,在表3的共识节点信息表中删除节点3的信息,并添加节点7作为共识节点,在表4所示的委托节点信息表中删除节点7的信息。Assume that the current consensus nodes in the blockchain are as shown in Table 3. As mentioned above, since the weight of node 3 and the sum of the weights of all consensus nodes satisfy the relationship f:3f+1, therefore, node 1, node 2 and node 4. The consensus on the transaction Tx5 can be successful, and the commission information will be updated based on the transaction Tx5. Specifically, taking node 1 as an example, after node 1 executes transaction Tx5 and reaches consensus successfully, it deletes the information of node 3 in the consensus node information table in Table 3, and adds node 7 as a consensus node. In the delegation shown in Table 4 Delete the information of node 7 from the node information table.
图7为本说明书一实施例中的共识节点的结构图,包括:Figure 7 is a structural diagram of a consensus node in an embodiment of this specification, including:
获取单元71,用于从区块链中获取多个共识节点的委托信息,所述委托信息用于指示各个所述共识节点关联的委托节点的数目,所述委托节点为所述区块链中委托任一所述共识节点进行共识的节点;The acquisition unit 71 is used to acquire the entrustment information of multiple consensus nodes from the blockchain. The entrustment information is used to indicate the number of entrustment nodes associated with each consensus node. The entrustment node is in the blockchain. A node that entrusts any of the consensus nodes to carry out consensus;
共识单元72,用于基于所述委托信息进行对共识提议的共识操作。The consensus unit 72 is configured to perform a consensus operation on the consensus proposal based on the delegation information.
在一种实施方式中,所述共识节点,还包括:接收单元,用于接收第一交易,所述第一交易由所述多个共识节点中的第二节点发送,用于委托所述多个共识节点中的第三节点进行共识;更新单元,用于根据所述第一交易更新所述委托信息。In one implementation, the consensus node further includes: a receiving unit, configured to receive a first transaction, the first transaction being sent by a second node among the plurality of consensus nodes, and used to entrust the plurality of consensus nodes to The third node among the consensus nodes performs consensus; an update unit is used to update the delegation information according to the first transaction.
在一种实施方式中,所述委托信息中包括共识节点信息表,所述共识节点信息表中包括各个共识节点的标识和权重,所述权重用于指示各个所述共识节点关联的委托节点的数目,所述更新单元具体用于:在所述共识节点信息表中删除所述第二节点的信息,将所述第三节点的权重加一。In one implementation, the delegation information includes a consensus node information table. The consensus node information table includes the identification and weight of each consensus node. The weight is used to indicate the delegation node associated with each consensus node. The update unit is specifically configured to: delete the information of the second node in the consensus node information table, and increase the weight of the third node by one.
在一种实施方式中,所述委托信息中还包括委托节点信息表,所述更新单元具体 用于:在委托节点信息表中记录所述第二节点对所述第三节点的委托。In one implementation, the delegation information further includes a delegation node information table, and the update unit is specifically configured to record the delegation of the second node to the third node in the delegation node information table.
在一种实施方式中,所述共识单元72具体用于:生成自身的对所述共识提议的签名,从其他共识节点接收所述其他共识节点对所述共识提议的签名,根据各个共识节点的权重信息计算获取的对所述共识提议的签名数,根据所述签名数确认共识是否成功。In one implementation, the consensus unit 72 is specifically configured to: generate its own signature for the consensus proposal, receive the signatures of the other consensus nodes for the consensus proposal from other consensus nodes, and generate The weight information is used to calculate the number of signatures obtained for the consensus proposal, and whether the consensus is successful is confirmed based on the number of signatures.
在一种实施方式中,所述第一节点的委托信息中还包括委托所述第一节点的第四节点的标识,所述共识节点还包括:生成单元,用于在对所述共识提议共识成功之后,根据所述共识提议生成第一区块,将所述第一区块发送给所述第四节点。In one implementation, the delegation information of the first node also includes an identification of a fourth node that delegates the first node, and the consensus node further includes: a generating unit for proposing a consensus on the consensus. After success, the first block is generated according to the consensus proposal, and the first block is sent to the fourth node.
在一种实施方式中,其中,所述区块链中包括智能合约,所述委托信息存储在所述智能合约的合约状态中,所述第一交易调用所述智能合约。In one implementation, the blockchain includes a smart contract, the delegation information is stored in a contract state of the smart contract, and the first transaction calls the smart contract.
在一种实施方式中,所述委托信息还包括恶意节点列表,所述接收单元还用于:接收第二交易,所述第二交易用于指示所述多个共识节点中的第五节点为恶意节点,所述更新单元还用于:执行所述第二交易,在所述共识节点信息表中删除所述第五节点的信息,在所述恶意节点列表中添加所述第五节点的标识和所述第五节点关联的委托节点的标识。In one implementation, the delegation information further includes a malicious node list, and the receiving unit is further configured to: receive a second transaction, where the second transaction is used to indicate that the fifth node among the plurality of consensus nodes is Malicious node, the update unit is also configured to: execute the second transaction, delete the information of the fifth node in the consensus node information table, and add the identification of the fifth node to the malicious node list The identifier of the delegation node associated with the fifth node.
在一种实施方式中,所述接收单元还用于,接收第三交易,所述第三交易用于指示所述多个共识节点中的第六节点为故障节点,执行所述第三交易,以在所述共识节点信息表中删除所述第六节点的信息、并在所述共识节点信息表中添加所述第六节点关联的委托节点的标识和权重。In one implementation, the receiving unit is further configured to receive a third transaction, the third transaction is used to indicate that the sixth node among the plurality of consensus nodes is a fault node, and execute the third transaction, To delete the information of the sixth node in the consensus node information table, and add the identification and weight of the delegation node associated with the sixth node in the consensus node information table.
在20世纪90年代,对于一个技术的改进可以很明显地区分是硬件上的改进(例如,对二极管、晶体管、开关等电路结构的改进)还是软件上的改进(对于方法流程的改进)。然而,随着技术的发展,当今的很多方法流程的改进已经可以视为硬件电路结构的直接改进。设计人员几乎都通过将改进的方法流程编程到硬件电路中来得到相应的硬件电路结构。因此,不能说一个方法流程的改进就不能用硬件实体模块来实现。例如,可编程逻辑器件(Programmable Logic Device,PLD)(例如现场可编程门阵列(Field Programmable Gate Array,FPGA))就是这样一种集成电路,其逻辑功能由用户对器件编程来确定。由设计人员自行编程来把一个数字系统“集成”在一片PLD上,而不需要请芯片制造厂商来设计和制作专用的集成电路芯片。而且,如今,取代手工地制作集成电路芯片,这种编程也多半改用“逻辑编译器(logic compiler)”软件来实现,它与程序开发撰写时所用的软件编译器相类似,而要编译之前的原始代码也得用特定的编程语言来撰写,此称之为硬件描述语言(Hardware Description Language,HDL),而HDL也并非仅有一种,而是有许多种,如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)等,目前最普遍使用的是VHDL(Very-High-Speed Integrated Circuit Hardware Description Language)与Verilog。本领域技术人员也应该清楚,只需要将方法流程用上述几种硬件描述语言稍作逻辑编程并编程到集成电路中,就可以很容易得到实现该逻辑方法流程的硬件电路。In the 1990s, improvements in a technology could be clearly distinguished as hardware improvements (for example, improvements in circuit structures such as diodes, transistors, switches, etc.) or software improvements (improvements in method processes). However, with the development of technology, many improvements in today's method processes can be regarded as direct improvements in hardware circuit structures. 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 of a method flow cannot be implemented using hardware entity modules. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic functions are determined by the user programming the device. Designers can program themselves to "integrate" a digital system on a PLD, instead of asking chip manufacturers to design and produce dedicated integrated circuit chips. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented using "logic compiler" software, which is similar to the software compiler used in program development and writing, and before compilation The original code must also be written in a specific programming language, which is called Hardware Description Language (HDL), and HDL is not just one kind, but there are many, 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., are currently the most commonly used The two are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that by simply logically programming the method flow using the above-mentioned hardware description languages and programming it into the integrated circuit, the hardware circuit that implements the logical method flow can be easily obtained.
控制器可以按任何适当的方式实现,例如,控制器可以采取例如微处理器或处理器以及存储可由该(微)处理器执行的计算机可读程序代码(例如软件或固件)的计算机可读介质、逻辑门、开关、专用集成电路(Application Specific Integrated Circuit,ASIC)、可编程逻辑控制器和嵌入微控制器的形式,控制器的例子包括但不限于以下微控制器:ARC 625D、Atmel AT91SAM、Microchip PIC18F26K20以及Silicone Labs C8051F320,存储器控制器还可以被实现为存储器的控制逻辑的一部分。本领域技术人员也知道,除了以纯计算机可读程序代码方式实现控制器以外,完全可以通过将方法步骤进行逻辑编程来使得控制器以逻辑门、开关、专用集成电路、可编程逻辑控制器和嵌入微控制器等的形式来实现相同功能。因此这种控制器可以被认为是一种硬件部件,而对其内包括的用于实现各种功能的装置也可以视为硬件部件内的结构。或者甚至,可以将用于实现各种功能的装置视为既可以是实现方法的软件模块又可以是硬件部件内的结构。The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer readable medium storing computer readable program code (eg, software or firmware) executable by the (micro)processor. , logic gates, switches, Application Specific Integrated Circuit (ASIC), programmable logic controllers and embedded microcontrollers. Examples of controllers include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, For Microchip PIC18F26K20 and Silicone Labs C8051F320, the memory controller can also be implemented as part of the memory's control logic. Those skilled in the art also know that in addition to implementing the controller in the form of pure computer-readable program code, the controller can be completely programmed with logic gates, switches, application-specific integrated circuits, programmable logic controllers and embedded logic by logically programming the method steps. Microcontroller, etc. to achieve the same function. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be considered as structures within the hardware component. Or even, the means for implementing various functions can be considered as structures within hardware components as well as software modules implementing the methods.
上述实施例阐明的系统、装置、模块或单元,具体可以由计算机芯片或实体实现,或者由具有某种功能的产品来实现。一种典型的实现设备为服务器系统。当然,本申请不排除随着未来计算机技术的发展,实现上述实施例功能的计算机例如可以为个人计算机、膝上型计算机、车载人机交互设备、蜂窝电话、相机电话、智能电话、个人数字助理、媒体播放器、导航设备、电子邮件设备、游戏控制台、平板计算机、可穿戴设备或者这些设备中的任何设备的组合。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, this application does not rule out 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, or a personal digital assistant. , media player, navigation device, email device, game console, tablet, wearable device, or a combination of any of these devices.
虽然本说明书一个或多个实施例提供了如实施例或流程图所述的方法操作步骤,但基于常规或者无创造性的手段可以包括更多或者更少的操作步骤。实施例中列举的步骤顺序仅仅为众多步骤执行顺序中的一种方式,不代表唯一的执行顺序。在实际中的装置或终端产品执行时,可以按照实施例或者附图所示的方法顺序执行或者并行执行(例如并行处理器或者多线程处理的环境,甚至为分布式数据处理环境)。术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、产品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、产品或者设备所固有的要素。在没有更多限制的情况下,并不排除在包括所述要素的过程、方法、产品或者设备中还存在另外的相同或等同要素。例如若使用到第一,第二等词语用来表示名称,而并不表示任何特定的顺序。Although one or more embodiments of this specification provide method operation steps as described in the embodiments or flow charts, more or fewer operation steps may be included based on conventional or non-inventive means. The sequence of steps listed in the embodiment is only one way of executing the sequence of many steps, and does not represent the only execution sequence. When the actual device or terminal product is executed, it may be executed sequentially or in parallel according to the methods shown in the embodiments or figures (for example, a parallel processor or a multi-thread processing environment, or even a distributed data processing environment). The terms "comprises," "comprises" or any other variation thereof are intended to cover a non-exclusive inclusion such that a process, method, product or apparatus including a list of elements includes not only those elements but also others not expressly listed elements, or also elements inherent to the process, method, product or equipment. Without further limitation, it does not exclude the presence of additional identical or equivalent elements in a process, method, product or apparatus including the stated elements. For example, if the words "first" and "second" are used to express names, they do not indicate any specific order.
为了描述的方便,描述以上装置时以功能分为各种模块分别描述。当然,在实施本说明书一个或多个时可以把各模块的功能在同一个或多个软件和/或硬件中实现,也可以将实现同一功能的模块由多个子模块或子单元的组合实现等。以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。For the convenience of description, when describing the above device, the functions are divided into various modules and described separately. Of course, when implementing one or more of this specification, the functions of each module can be implemented in the same or multiple software and/or hardware, or the modules that implement the same function can be implemented by a combination of multiple sub-modules or sub-units, etc. . The device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated. to another system, or some features can be ignored, or not implemented. On the other hand, the coupling or direct coupling or communication connection between each other shown or discussed may be through some interfaces, and the indirect coupling or communication connection of the devices or units may be in electrical, mechanical or other forms.
本发明是参照根据本发明实施例的方法、装置(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中 的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each process and/or block in the flowchart illustrations and/or block diagrams, and combinations of processes and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing device to produce a machine, such that the instructions executed by the processor of the computer or other programmable data processing device produce a use A device for implementing the functions specified in one process or processes of the flowchart and/or one block or blocks of the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory that causes a computer or other programmable data processing apparatus to operate in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction means, the instructions The device implements the functions specified in a process or processes of the flowchart and/or a block or blocks of the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions may also be loaded onto a computer or other programmable data processing device, causing a series of operating steps to be performed on the computer or other programmable device to produce computer-implemented processing, thereby executing on the computer or other programmable device. Instructions provide steps for implementing the functions specified in a process or processes of a flowchart diagram and/or a block or blocks of a block diagram.
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。Memory may include non-permanent storage in computer-readable media, random access memory (RAM) and/or non-volatile memory in the form of read-only memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储、石墨烯存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。Computer-readable media includes both persistent and non-volatile, removable and non-removable media that can be implemented by any method or technology for storage of information. Information may be computer-readable instructions, data structures, modules of programs, 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), and read-only memory. (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, Magnetic tape, magnetic tape storage, graphene storage or other magnetic storage devices or any other non-transmission medium can be used to store information that can be accessed by a computing device. As defined in this article, computer-readable media does not include transitory media, such as modulated data signals and carrier waves.
本领域技术人员应明白,本说明书一个或多个实施例可提供为方法、系统或计算机程序产品。因此,本说明书一个或多个实施例可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本说明书一个或多个实施例可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。It should be understood by those skilled in the art that one or more embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, one or more embodiments of the present description may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment that combines software and hardware aspects. Furthermore, one or more embodiments of the present description may employ a computer program implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein. Product form.
本说明书一个或多个实施例可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本本说明书一个或多个实施例,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。One or more embodiments of this specification may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. 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 the present description may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including storage devices.
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部 分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。在本说明书的描述中,参考术语“一个实施例”、“一些实施例”、“示例”、“具体示例”、或“一些示例”等的描述意指结合该实施例或示例描述的具体特征、结构、材料或者特点包含于本说明书的至少一个实施例或示例中。在本说明书中,对上述术语的示意性表述不必须针对的是相同的实施例或示例。而且,描述的具体特征、结构、材料或者特点可以在任一个或多个实施例或示例中以合适的方式结合。此外,在不相互矛盾的情况下,本领域的技术人员可以将本说明书中描述的不同实施例或示例以及不同实施例或示例的特征进行结合和组合。Each embodiment in this specification is described in a progressive manner. The same and similar parts between the various embodiments can be referred to each other. 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. For relevant details, please refer to the partial description of the method embodiment. In the description of this specification, reference to the terms "one embodiment," "some embodiments," "an example," "specific examples," or "some examples" or the like means that specific features are described in connection with the embodiment or example. , structures, materials or features are included in at least one embodiment or example of this specification. In this specification, the schematic expressions of the above terms are not necessarily directed to the same embodiment or example. Furthermore, the specific features, structures, materials or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, those skilled in the art may combine and combine different embodiments or examples and features of different embodiments or examples described in this specification unless they are inconsistent with each other.
以上所述仅为本说明书一个或多个实施例的实施例而已,并不用于限制本本说明书一个或多个实施例。对于本领域技术人员来说,本说明书一个或多个实施例可以有各种更改和变化。凡在本说明书的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在权利要求范围之内。The above descriptions are only examples of one or more embodiments of this specification, and are not intended to limit one or more embodiments of this specification. To those skilled in the art, various modifications and changes may be made to one or more embodiments of this specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this specification shall be included in the scope of the claims.

Claims (15)

  1. 一种共识方法,由区块链中第一节点执行,所述区块链包括多个共识节点,所述第一节点为所述多个共识节点中的一个,所述方法包括:A consensus method is executed by a first node in a blockchain, the blockchain includes multiple consensus nodes, the first node is one of the multiple consensus nodes, the method includes:
    从区块链中获取委托信息,所述委托信息用于指示各个所述共识节点关联的委托节点的数目,所述委托节点为所述区块链中委托任一所述共识节点进行共识的节点;Obtain entrustment information from the blockchain. The entrustment information is used to indicate the number of entrustment nodes associated with each consensus node. The entrustment node is a node in the blockchain that entrusts any of the consensus nodes to perform consensus. ;
    基于所述委托信息进行对共识提议的共识操作。The consensus operation on the consensus proposal is performed based on the delegation information.
  2. 根据权利要求1所述的方法,所述方法还包括:The method of claim 1, further comprising:
    接收第一交易,所述第一交易由所述多个共识节点中的第二节点发送,用于委托所述多个共识节点中的第三节点进行共识;Receive a first transaction, the first transaction is sent by a second node among the plurality of consensus nodes, and is used to entrust a third node among the plurality of consensus nodes to carry out consensus;
    根据所述第一交易在所述委托信息中删除所述第二节点的信息,更新所述第三节点关联的委托节点的数目。According to the first transaction, the information of the second node is deleted from the delegation information, and the number of delegation nodes associated with the third node is updated.
  3. 根据权利要求2所述的方法,所述委托信息中包括共识节点信息表,所述共识节点信息表中包括各个共识节点的标识和权重,所述权重用于指示各个所述共识节点关联的委托节点的数目,所述根据所述第一交易更新所述委托信息包括:The method according to claim 2, the delegation information includes a consensus node information table, the consensus node information table includes the identification and weight of each consensus node, the weight is used to indicate the delegation associated with each of the consensus nodes. The number of nodes. The updating of the delegation information according to the first transaction includes:
    在所述共识节点信息表中删除所述第二节点的信息,将所述第三节点的权重加一。Delete the information of the second node in the consensus node information table, and add one to the weight of the third node.
  4. 根据权利要求3所述的方法,所述委托信息中还包括委托节点信息表,所述方法还包括:在委托节点信息表中记录所述第二节点对所述第三节点的委托。According to the method of claim 3, the delegation information further includes a delegation node information table, and the method further includes: recording the delegation of the second node to the third node in the delegation node information table.
  5. 根据权利要求1或2所述的方法,所述基于所述委托信息进行对共识提议的共识操作包括:生成自身的对所述共识提议的签名,从其他共识节点接收所述其他共识节点对所述共识提议的签名,根据各个共识节点关联的委托节点的数目计算获取的对所述共识提议的签名数,根据所述签名数确认共识是否成功。According to the method of claim 1 or 2, the consensus operation on the consensus proposal based on the delegation information includes: generating its own signature on the consensus proposal, and receiving the signature of the other consensus node on the consensus proposal from other consensus nodes. For the signature of the consensus proposal, the number of signatures obtained for the consensus proposal is calculated based on the number of delegation nodes associated with each consensus node, and whether the consensus is successful is confirmed based on the number of signatures.
  6. 根据权利要求1或2所述的方法,所述委托信息中还包括委托所述第一节点的第四节点的标识,所述方法还包括:The method according to claim 1 or 2, wherein the delegation information further includes an identification of a fourth node that delegates the first node, and the method further includes:
    在对所述共识提议共识成功之后,根据所述共识提议生成第一区块,将所述第一区块发送给所述第四节点。After the consensus proposal is successfully reached, a first block is generated according to the consensus proposal, and the first block is sent to the fourth node.
  7. 根据权利要求2所述的方法,其中,所述区块链中包括智能合约,所述委托信息存储在所述智能合约的合约状态中,所述第一交易调用所述智能合约。The method of claim 2, wherein the blockchain includes a smart contract, the delegation information is stored in a contract state of the smart contract, and the first transaction calls the smart contract.
  8. 根据权利要求3所述的方法,所述委托信息还包括恶意节点列表,所述方法还包括:接收第二交易,所述第二交易用于指示所述多个共识节点中的第五节点为恶意节点,执行所述第二交易,在所述共识节点信息表中删除所述第五节点的信息,在所述恶意节点列表中添加所述第五节点的标识和所述第五节点关联的委托节点的标识。The method of claim 3, wherein the delegation information further includes a list of malicious nodes, and the method further includes: receiving a second transaction, the second transaction being used to indicate that a fifth node among the plurality of consensus nodes is The malicious node executes the second transaction, deletes the information of the fifth node in the consensus node information table, and adds the identifier of the fifth node and the information associated with the fifth node in the malicious node list. The identifier of the delegate node.
  9. 根据权利要求3所述的方法,还包括,接收第三交易,所述第三交易用于指示所述多个共识节点中的第六节点为故障节点,执行所述第三交易,以在所述共识节点信息表中删除所述第六节点的信息、并在所述共识节点信息表中添加所述第六节点关联的委托节点的标识和权重。The method of claim 3, further comprising: receiving a third transaction, the third transaction being used to indicate that a sixth node among the plurality of consensus nodes is a fault node, and executing the third transaction to ensure that the sixth node among the plurality of consensus nodes is a fault node. Delete the information of the sixth node from the consensus node information table, and add the identification and weight of the delegation node associated with the sixth node to the consensus node information table.
  10. 一种区块链节点,包括:A blockchain node including:
    获取单元,用于从区块链中获取委托信息,所述委托信息用于指示各个所述共识节点关联的委托节点的数目,所述委托节点为所述区块链中委托任一所述共识节点进行共识的节点;An acquisition unit is used to obtain entrustment information from the blockchain. The entrustment information is used to indicate the number of entrustment nodes associated with each of the consensus nodes. The entrustment node is the entrustment of any one of the consensuses in the blockchain. The node where the node performs consensus;
    共识单元,用于基于所述委托信息进行对共识提议的共识操作。A consensus unit is used to perform consensus operations on consensus proposals based on the delegation information.
  11. 根据权利要求10所述的节点,还包括:The node of claim 10, further comprising:
    接收单元,用于接收第一交易,所述第一交易由所述多个共识节点中的第二节点发送,用于委托所述多个共识节点中的第三节点进行共识;A receiving unit, configured to receive a first transaction sent by a second node among the plurality of consensus nodes, and to entrust a third node among the plurality of consensus nodes to perform consensus;
    更新单元,用于根据所述第一交易在所述委托信息中删除所述第二节点的信息,更新所述第三节点关联的委托节点的数目。An update unit, configured to delete the information of the second node in the delegation information according to the first transaction, and update the number of delegation nodes associated with the third node.
  12. 根据权利要求11所述的节点,所述委托信息中包括共识节点信息表,所述共识节点信息表中包括各个共识节点的标识和权重,所述权重用于指示各个所述共识节点关联的委托节点的数目,所述更新单元具体用于:The node according to claim 11, the delegation information includes a consensus node information table, the consensus node information table includes the identification and weight of each consensus node, the weight is used to indicate the delegation associated with each of the consensus nodes. The number of nodes, the update unit is specifically used to:
    在所述共识节点信息表中删除所述第二节点的信息,将所述第三节点的权重加一。Delete the information of the second node in the consensus node information table, and add one to the weight of the third node.
  13. 根据权利要求10或11所述的节点,所述共识单元具体用于:生成自身的对所述共识提议的签名,从其他共识节点接收所述其他共识节点对所述共识提议的签名,根据各个共识节点关联的委托节点的数目计算获取的对所述共识提议的签名数,根据所述签名数确认共识是否成功。According to the node according to claim 10 or 11, the consensus unit is specifically configured to: generate its own signature for the consensus proposal, receive the signatures of the other consensus nodes for the consensus proposal from other consensus nodes, and according to each The number of delegated nodes associated with the consensus node is calculated by calculating the number of signatures obtained for the consensus proposal, and whether the consensus is successful is confirmed based on the number of signatures.
  14. 一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算机中执行时,令计算机执行权利要求1-9中任一项的所述的方法。A computer-readable storage medium on which a computer program is stored. When the computer program is executed in a computer, the computer is caused to perform the method described in any one of claims 1-9.
  15. 一种共识节点,包括存储器和处理器,所述存储器中存储有可执行代码,所述处理器执行所述可执行代码时,实现权利要求1-9中任一项所述的方法。A consensus node includes a memory and a processor. The memory stores executable code. When the processor executes the executable code, it implements the method described in any one of claims 1-9.
PCT/CN2022/135666 2022-03-30 2022-11-30 Consensus method and blockchain node WO2023185059A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210325860.7 2022-03-30
CN202210325860.7A CN114710507B (en) 2022-03-30 2022-03-30 Consensus method, blockchain node, medium and consensus node

Publications (1)

Publication Number Publication Date
WO2023185059A1 true WO2023185059A1 (en) 2023-10-05

Family

ID=82170823

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/135666 WO2023185059A1 (en) 2022-03-30 2022-11-30 Consensus method and blockchain node

Country Status (2)

Country Link
CN (1) CN114710507B (en)
WO (1) WO2023185059A1 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114710507B (en) * 2022-03-30 2023-10-27 蚂蚁区块链科技(上海)有限公司 Consensus method, blockchain node, medium and consensus node
CN115658807A (en) * 2022-09-30 2023-01-31 蚂蚁区块链科技(上海)有限公司 Consensus method in block chain system, consensus node and block chain system
CN115665164A (en) * 2022-09-30 2023-01-31 蚂蚁区块链科技(上海)有限公司 Transaction processing method and device in blockchain system and blockchain system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190354518A1 (en) * 2018-05-01 2019-11-21 Michael Zochowski Chain mesh network for decentralized transaction systems
CN111539726A (en) * 2020-04-20 2020-08-14 中国工商银行股份有限公司 Block chain consensus system and method
CN112184454A (en) * 2020-11-09 2021-01-05 上海优扬新媒信息技术有限公司 Block chain consensus method, device, system and storage medium
CN114025012A (en) * 2022-01-10 2022-02-08 国网电子商务有限公司 Node selection method, device, storage medium and equipment based on credit grouping
CN114710507A (en) * 2022-03-30 2022-07-05 蚂蚁区块链科技(上海)有限公司 Consensus method and block link point

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109104396B (en) * 2017-06-21 2021-03-16 上海钜真金融信息服务有限公司 Block chain agent authorization method and medium based on agent signature
CN108259235B (en) * 2018-01-04 2019-11-22 杭州复杂美科技有限公司 A kind of block chain accounting nodes selection method
CN108133420B (en) * 2018-01-10 2020-09-11 杭州复杂美科技有限公司 Committee consensus method of block chain
CN108737175B (en) * 2018-05-19 2021-04-23 上海分布信息科技有限公司 Node management method and implementation system thereof
US11343073B2 (en) * 2019-06-18 2022-05-24 Electronics And Telecommunications Research Institute Apparatus and method for achieving distributed consensus based on decentralized byzantine fault tolerance
CN113269542A (en) * 2021-04-07 2021-08-17 北京邮电大学 Consensus method, device and storage medium for block chain system
CN113783697B (en) * 2021-08-18 2022-07-29 区块链新科技(广州)有限公司 Committee-based data broadcast service certification consensus protocol application method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190354518A1 (en) * 2018-05-01 2019-11-21 Michael Zochowski Chain mesh network for decentralized transaction systems
CN111539726A (en) * 2020-04-20 2020-08-14 中国工商银行股份有限公司 Block chain consensus system and method
CN112184454A (en) * 2020-11-09 2021-01-05 上海优扬新媒信息技术有限公司 Block chain consensus method, device, system and storage medium
CN114025012A (en) * 2022-01-10 2022-02-08 国网电子商务有限公司 Node selection method, device, storage medium and equipment based on credit grouping
CN114710507A (en) * 2022-03-30 2022-07-05 蚂蚁区块链科技(上海)有限公司 Consensus method and block link point

Also Published As

Publication number Publication date
CN114710507B (en) 2023-10-27
CN114710507A (en) 2022-07-05

Similar Documents

Publication Publication Date Title
WO2023185059A1 (en) Consensus method and blockchain node
TWI737944B (en) Block chain-based transaction execution method and device, and electronic equipment
TWI679874B (en) Cross-blockchain authentication method and device, and electronic equipment
US11243945B2 (en) Distributed database having blockchain attributes
US11847135B2 (en) Blockchain node and transaction method
US20200341951A1 (en) Extracting data from a blockchain network
US20190354518A1 (en) Chain mesh network for decentralized transaction systems
US20190172026A1 (en) Cross blockchain secure transactions
US11615078B2 (en) Blockchain-based transaction methods
WO2020211484A1 (en) Data processing method and device, block chain client and block chain node
TW202008196A (en) Transaction method and system based on centralized settlement and block chain deposit certification
TW202008235A (en) Transaction method and system based on centralized settlement and block chain storage
TW201822033A (en) Resource processing method and apparatus
CN111066047A (en) Implementing a blockchain based workflow
US11520737B2 (en) Blockchain-as-a-service integrated hybrid object storage system in multi-cloud computing environment
CN112966311B (en) Intelligent contract checking method and device and electronic equipment
WO2023231337A1 (en) Method for executing transaction in blockchain, and master node and slave node of blockchain
CN114827165B (en) Method and block link point for grouping multiple transactions
WO2023231335A1 (en) Method for executing transaction in blockchain, and master node of blockchain
WO2023231336A1 (en) Method for executing transaction and blockchain node
WO2024001024A1 (en) Method for executing transaction in blockchain system, and blockchain system and nodes
WO2023160085A1 (en) Method for executing transaction, blockchain, master node, and slave node
CN114936256A (en) Method for executing transaction in block chain and block chain link point
US20200202355A1 (en) Storage and execution of smart contracts in blockchains
Dinh et al. A blueprint for interoperable blockchains

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22934877

Country of ref document: EP

Kind code of ref document: A1