[go: up one dir, main page]

CN111507840B - Block chain consensus method, apparatus, computer and readable storage medium - Google Patents

Block chain consensus method, apparatus, computer and readable storage medium Download PDF

Info

Publication number
CN111507840B
CN111507840B CN202010295981.2A CN202010295981A CN111507840B CN 111507840 B CN111507840 B CN 111507840B CN 202010295981 A CN202010295981 A CN 202010295981A CN 111507840 B CN111507840 B CN 111507840B
Authority
CN
China
Prior art keywords
consensus
stage
block
result
local
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN202010295981.2A
Other languages
Chinese (zh)
Other versions
CN111507840A (en
Inventor
刘攀
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tenpay Payment Technology Co Ltd
Original Assignee
Tenpay Payment Technology Co Ltd
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 Tenpay Payment Technology Co Ltd filed Critical Tenpay Payment Technology Co Ltd
Priority to CN202010295981.2A priority Critical patent/CN111507840B/en
Publication of CN111507840A publication Critical patent/CN111507840A/en
Application granted granted Critical
Publication of CN111507840B publication Critical patent/CN111507840B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures
    • 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
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction

Landscapes

  • Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Accounting & Taxation (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Finance (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Strategic Management (AREA)
  • General Business, Economics & Management (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Technology Law (AREA)
  • Health & Medical Sciences (AREA)
  • Bioethics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Hardware Design (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer And Data Communications (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the application discloses a block chain consensus method, a device, a computer and a readable storage medium, comprising the following steps: in a first-stage consensus period, acquiring a first-stage consensus result aiming at a transaction block and sent by at least two consensus nodes; determining the number of first-stage voting results according to the local consensus result, the first-stage consensus result and the first-stage consensus result for the transaction block; if the number of the voting results in the first stage is smaller than a first number threshold, generating a local empty block in the second stage; in the second-stage consensus period, broadcasting a second-stage local empty block to at least two consensus nodes, and acquiring a second-stage consensus result sent by the at least two consensus nodes; and determining the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result. By adopting the method and the device, the efficiency of block chain consensus can be improved.

Description

Block chain consensus method, apparatus, computer and readable storage medium
Technical Field
The present disclosure relates to the field of blockchain technologies, and in particular, to a blockchain consensus method, a blockchain consensus device, a blockchain consensus computer, and a readable storage medium.
Background
With the increasing maturity of the blockchain technology and the characteristics of decentralization and the like of the blockchain, the blockchain is increasingly widely applied, wherein currently, the obtained transaction block is subjected to consensus through a consensus node in the blockchain, and the uplink result of the transaction block is determined according to the consensus result so as to ensure the safety of blockchain data. Therefore, management of blockchain consensus is also an important issue for better ensuring the decentralization characteristics of blockchains and the security of blockchain data. Currently, when a transaction block is uplink in a blockchain, an consensus node in a blockchain network can perform consensus on the transaction block, the transaction block is added to the blockchain only when the transaction block passes the consensus, the uplink result of the transaction block is determined to be an uplink success result, and in the process of consensus on the transaction block by the consensus node, abnormal conditions (such as network factors and the like) can possibly occur, so that whether the transaction block passes the consensus cannot be determined, namely the uplink result of the transaction block cannot be determined, the consensus process of the transaction block is interrupted, and the efficiency of blockchain consensus is reduced.
Disclosure of Invention
The embodiment of the application provides a block chain consensus method and device, which can improve the efficiency of block chain consensus.
In one aspect, an embodiment of the present application provides a blockchain consensus method, including:
in a first-stage consensus period, acquiring a first-stage consensus result aiming at a transaction block and sent by at least two consensus nodes;
determining the number of first-stage voting results according to the local consensus result for the transaction block and the first-stage consensus result;
if the number of the voting results in the first stage is smaller than a first number threshold, generating a local empty block in the second stage; the local empty block in the second stage is a block with empty transaction data;
in a second-stage consensus period, broadcasting the second-stage local empty block to the at least two consensus nodes to obtain a second-stage consensus result sent by the at least two consensus nodes; the first-stage consensus period and the second-stage consensus period belong to the consensus period for the transaction block, and the first-stage consensus period is earlier than the second-stage consensus period;
and determining the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result.
Wherein, the method further comprises the following steps:
if the number of the first-stage voting results is greater than or equal to the first number threshold, counting the number of first-stage voting empty blocks in the first-stage consensus result; the first-stage voting empty block is generated by a consensus node which detects that the transaction block does not meet the consensus condition in the at least two consensus nodes;
determining the number of first empty blocks according to the local consensus result and the number of first-stage voting empty blocks;
and if the number of the first empty blocks is larger than a second number threshold, generating the second stage local empty blocks.
Wherein determining the number of the first empty blocks according to the local consensus result and the number of the first-stage voting empty blocks includes:
if the local consensus result is a block voting success result aiming at the transaction block, determining the number of the first-stage voting empty blocks as the first empty block number;
and if the local consensus result is a first stage local empty block, taking the sum of the first stage local empty block and the number of the first stage voting empty blocks as the first empty block number.
Wherein, the method further comprises the following steps:
And if the transaction block is not acquired in the first-stage consensus period, generating the first-stage local empty block, taking the first-stage local empty block as the local consensus result, and broadcasting the local consensus result to the at least two consensus nodes.
Wherein, the method further comprises the following steps:
if the transaction block is acquired in the first-stage consensus period, verifying the transaction block;
if the transaction block passes the verification, generating a block voting success result aiming at the transaction block, taking the block voting success result aiming at the transaction block as the local consensus result, and broadcasting the local consensus result to the at least two consensus nodes;
and if the transaction block verification is not passed, generating the first-stage local empty block, taking the first-stage local empty block as the local consensus result, and broadcasting the local consensus result to the at least two consensus nodes.
Wherein, the method further comprises the following steps:
if the number of the first-stage voting results is greater than or equal to the first number threshold, counting the number of first-stage voting success results in the first-stage consensus results; the successful voting result in the first stage is generated by the consensus node which detects that the transaction block meets the consensus condition in the at least two consensus nodes;
Determining a first voting success number according to the local consensus result and the number of the first voting success results;
if the first voting success number is greater than or equal to the first number threshold, generating a second-stage local consensus success result, broadcasting the second-stage local consensus success result to the at least two consensus nodes, and acquiring a second-stage consensus result sent by the at least two consensus nodes;
and determining the uplink result of the transaction block according to the local consensus success result of the second stage and the second stage consensus result.
Wherein determining the first number of votes according to the number of local consensus results and the first-stage voting success results includes:
if the local consensus result is a block voting success result aiming at the transaction block, taking the sum of the local consensus result and the number of the first-stage voting success results as the first voting success number;
and if the local consensus result is the first stage local empty block, determining the number of the first stage voting success results as the first voting success number.
Wherein determining the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result includes:
taking the number of second-stage consensus success results in the second-stage consensus results as a second voting success number;
if the second voting success number is greater than or equal to the first number threshold, uploading the transaction block to a block chain, and determining that the uplink result of the transaction block is an uplink success result;
and if the second voting success number is smaller than the first number threshold, deleting the transaction block, and determining that the uplink result of the transaction block is an uplink failure result.
Wherein determining the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result includes:
counting the number of second-stage consensus empty blocks in the second-stage consensus result;
taking the sum of the number of the second-stage local empty blocks and the number of the second-stage consensus empty blocks as a second empty block number;
and if the second empty block number is greater than a second number threshold, deleting the transaction block, and determining that the uplink result of the transaction block is a uplink failure result.
Wherein determining the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result includes:
determining the number of voting results in the second stage according to the local empty block in the second stage and the consensus result in the second stage;
and if the number of the voting results in the second stage is smaller than the first number threshold, deleting the transaction block, and determining that the uplink result of the transaction block is a uplink failure result.
Wherein, the method further comprises the following steps:
if the uplink result of the transaction block is the uplink failure result, acquiring a block generation node of the transaction block;
adding the block generating node into a permission limiting node set; the authority limit node set comprises consensus nodes without generating block authorities;
and acquiring the storage time length of the block generation node in the authority limit set, deleting the block generation node in the authority limit set if the storage time length is longer than the authority limit time, and recovering the generation block authority of the block generation node.
In one aspect, an embodiment of the present application provides a blockchain consensus device, where the device includes:
The consensus acquisition module is used for acquiring a first-stage consensus result aiming at the transaction block and sent by at least two consensus nodes in a first-stage consensus period;
the voting number determining module is used for determining the number of the first-stage voting results according to the local consensus result aiming at the transaction block and the first-stage consensus result;
the first empty block generation module is used for generating a second stage local empty block if the number of the voting results in the first stage is smaller than a first number threshold value; the local empty block in the second stage is a block with empty transaction data;
the first consensus interaction module is used for broadcasting the second-stage local empty block to the at least two consensus nodes in a second-stage consensus period to acquire a second-stage consensus result sent by the at least two consensus nodes; the first-stage consensus period and the second-stage consensus period belong to the consensus period for the transaction block, and the first-stage consensus period is earlier than the second-stage consensus period;
and the uplink result determining module is used for determining the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result.
Wherein, the device further includes:
the empty block statistics module is used for counting the number of the first-stage voting empty blocks in the first-stage consensus result if the number of the first-stage voting results is greater than or equal to the first number threshold; the first-stage voting empty block is generated by a consensus node which detects that the transaction block does not meet the consensus condition in the at least two consensus nodes;
the empty block statistics module is further configured to determine a first number of empty blocks according to the local consensus result and the first number of empty blocks voted in the first stage;
and the second empty block generating module is used for generating the second-stage local empty block if the number of the first empty blocks is larger than a second number threshold value.
Wherein, in the aspect of determining the first number of empty blocks according to the local consensus result and the number of empty blocks in the first stage, the empty block statistics module includes:
a first number determining unit configured to determine the number of first-stage voting empty blocks as the first number of empty blocks if the local consensus result is a block voting success result for the transaction block;
the first number determining unit is further configured to, if the local consensus result is a first-stage local empty block, set a sum of the number of first-stage local empty blocks and the number of first-stage voting empty blocks as the first empty block number.
Wherein, the device further includes:
and the second consensus interaction module is used for generating the first-stage local empty block if the transaction block is not acquired in the first-stage consensus period, taking the first-stage local empty block as the local consensus result, and broadcasting the local consensus result to the at least two consensus nodes.
Wherein, the device further includes:
the block verification module is used for verifying the transaction block if the transaction block is obtained in the first-stage consensus period;
a first result generation module, configured to generate a block voting success result for the transaction block if the transaction block is verified to pass, take the block voting success result for the transaction block as the local consensus result, and broadcast the local consensus result to the at least two consensus nodes;
and the third empty block generating module is used for generating the first-stage local empty block if the transaction block is not verified, taking the first-stage local empty block as the local consensus result, and broadcasting the local consensus result to the at least two consensus nodes.
Wherein, the device further includes:
the success statistics module is used for counting the number of first-stage voting success results in the first-stage consensus results if the number of the first-stage voting results is larger than or equal to the first number threshold; the successful voting result in the first stage is generated by the consensus node which detects that the transaction block meets the consensus condition in the at least two consensus nodes;
the success statistics module is further configured to determine a first number of votes success according to the local consensus result and the number of votes success in the first stage;
the second result generation module is used for generating a second-stage local consensus success result if the first voting success number is greater than or equal to the first number threshold value, broadcasting the second-stage local consensus success result to the at least two consensus nodes, and acquiring a second-stage consensus result sent by the at least two consensus nodes;
the uplink result determining module is configured to determine an uplink result of the transaction block according to the second-stage local consensus success result and the second-stage consensus result.
Wherein, in the aspect of determining the first voting success number according to the local consensus result and the number of the first voting success results, the success statistics module includes:
A second number determining unit, configured to, if the local consensus result is a block voting success result for the transaction block, take a sum of the local consensus result and the number of first-stage voting success results as the first voting success number;
the second number determining unit is further configured to determine, if the local consensus result is a first stage local empty block, the number of voting success results in the first stage as the first voting success number.
Wherein, the uplink result determining module includes:
a third number determining unit, configured to use the number of second-stage consensus success results in the second-stage consensus results as a second voting success number;
the uplink success determining unit is configured to upload the transaction block to a blockchain if the second number of votes success is greater than or equal to the first number threshold, and determine that the uplink result of the transaction block is an uplink success result;
and the uplink failure determining unit is used for deleting the transaction block if the second voting success number is smaller than the first number threshold value, and determining that the uplink result of the transaction block is the uplink failure result.
Wherein, the uplink result determining module includes:
the empty block number counting unit is used for counting the number of second-stage consensus empty blocks in the second-stage consensus result;
the above-mentioned empty block quantity statistics unit, is also used for regarding the sum of the above-mentioned second stage local empty block and above-mentioned second stage consensus empty block quantity as the second empty block quantity;
the uplink failure determining unit is further configured to delete the transaction block if the second number of empty blocks is greater than a second number threshold, and determine that the uplink result of the transaction block is the uplink failure result.
Wherein, the uplink result determining module includes:
the voting result statistics unit is used for determining the number of the voting results of the second stage according to the local empty block of the second stage and the consensus result of the second stage;
the uplink failure determining unit is further configured to delete the transaction block if the number of voting results in the second stage is smaller than the first number threshold, and determine that the uplink result of the transaction block is the uplink failure result.
Wherein, the device further includes:
the generation node acquisition module is used for acquiring a block generation node of the transaction block if the uplink result of the transaction block is a uplink failure result;
The node adding module is used for adding the block generating node into the authority limit node set; the authority limit node set comprises consensus nodes without generating block authorities;
and the permission updating module is used for acquiring the storage time length of the block generating node in the permission limit set, deleting the block generating node in the permission limit set and recovering the generating block permission of the block generating node if the storage time length is longer than the permission limit time.
In one aspect, a computer device is provided, including a processor, a memory, and an input/output interface;
the processor is respectively connected with the memory and the input/output interface, wherein the input/output interface is used for data interaction of each node in the blockchain, the memory is used for storing program codes, and the processor is used for calling the program codes to execute the blockchain consensus method as implemented in one aspect of the embodiment of the application.
An aspect of the present embodiments provides a computer readable storage medium storing a computer program comprising program instructions that, when executed by a processor, perform a blockchain consensus method as implemented in an aspect of the embodiments of the present application.
Implementation of the embodiment of the application has the following beneficial effects:
in the embodiment of the application, a first-stage consensus result sent by at least two consensus nodes and aiming at a transaction block is obtained in a first-stage consensus period; determining the number of first-stage voting results according to the local consensus result, the first-stage consensus result and the first-stage consensus result for the transaction block; if the number of the voting results in the first stage is smaller than a first number threshold, generating a local empty block in the second stage; in the second-stage consensus period, broadcasting a second-stage local empty block to at least two consensus nodes, and acquiring a second-stage consensus result sent by the at least two consensus nodes; and determining the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result. The obtained transaction block is subjected to two-time consensus, and the time is limited in each consensus stage, namely the transaction block is subjected to consensus in a first-stage consensus period and a second-stage consensus period, so that even if abnormal conditions occur in the consensus process of the transaction block, the consensus process cannot be interrupted when the uplink result of the transaction block cannot be determined, a null block is generated, and the null block is used as a local consensus result of the corresponding stage, so that a local node can continuously execute the subsequent consensus process of the transaction block, and the efficiency of block chain consensus is improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of a blockchain consensus network provided in an embodiment of the present application;
FIG. 2 is a block chain consensus architecture diagram provided in an embodiment of the present application;
FIG. 3 is a schematic diagram of a blockchain consensus scenario provided by an embodiment of the present application;
FIG. 4 is a flowchart of a blockchain consensus method provided by an embodiment of the present application;
FIG. 5 is a schematic block chain consensus flowchart provided in an embodiment of the present application;
fig. 6 is a schematic diagram of a first-stage local consensus result generation scenario provided in an embodiment of the present application;
FIG. 7 is a diagram of a determining scenario of a uplink result according to an embodiment of the present application;
FIG. 8 is a schematic diagram of a block chain consensus device according to an embodiment of the present application;
fig. 9 is a schematic structural diagram of a computer device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are only some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, are intended to be within the scope of the present application.
In the embodiment of the present application, the blockchain consensus is performed, specifically, the received transaction block is subjected to consensus verification through two stages, and when the transaction block passes through the consensus after the two stages, the transaction block is uplink, wherein, partial nouns mentioned in the embodiment of the present application are introduced.
1. Blockchain: in a narrow sense, the blockchain is a chain data structure taking a block as a basic unit, and the block uses a digital abstract to verify the previous transaction history, so that the requirements of tamper resistance and expandability in a distributed billing scene are met; in a broad sense, blockchain also refers to distributed accounting techniques implemented by blockchain structures, including distributed consensus, privacy and security protection, point-to-point communication techniques, network protocols, smart contracts, and the like. The goal of the blockchain is to implement a distributed data logging ledger that allows only additions and not deletions. The basic structure of the ledger floor is a linear linked list. The linked list is formed by serially connecting blocks, the Hash value of the preceding block is recorded in the following blocks, and whether each block (and the transaction in the block) is legal or not can be rapidly checked by calculating the Hash value. If a node in the network proposes to add a new block, it must be acknowledged by the consensus mechanism.
2. Block (Block): all transactions and status results occurring within a period of time are recorded and are a consensus of the current ledger status. Specifically, for a blockchain, each time data is written, the transaction process described above creates a block. The block consists of a block head and a block body, wherein transaction data is stored in the block body, and a hash value, a block height, a time stamp and the like corresponding to the block body are recorded in the block head. In this embodiment, the empty block is a block with an empty block body, or a block with an empty block head and an empty block body, or may be empty data.
3. Consensus node: nodes that can make a consensus on the received transaction block, each consensus node can be considered to constitute a consensus network. Wherein each transaction block can be added to the blockchain for storage only after consensus through the consensus node.
Referring to fig. 1, fig. 1 is a schematic diagram of a blockchain consensus network provided in an embodiment of the present application, as shown in fig. 1, a consensus network 100 refers to a network for sharing data between consensus nodes, and each consensus node may perform consensus on an obtained transaction block, where the consensus network 100 may include a plurality of consensus nodes 101, and the plurality of consensus nodes 101 may refer to each computer device in the consensus network 100. Wherein each consensus node 101 may receive input information during normal operation and maintain shared data within the consensus network 100 based on the received input information. In order to ensure information interworking in the consensus network 100, information connections may exist between the consensus nodes 101 in the consensus network 100, and information transmission may be performed between the consensus nodes 101 through the information connections. For example, when any consensus node in the consensus network 100 receives input information, other consensus nodes in the consensus network 100 acquire the input information according to a consensus algorithm, perform consensus on the input information, and store the input information as data in shared data after the input information is successfully consensus, so that all the data stored in the consensus nodes in the consensus network 100 are consistent, and the data stored in each consensus node is consensus-passed, thereby improving the security of the data in the block chain.
The computer device may be a server or a terminal device, or may be a system formed by a server and a terminal device, where the terminal device may be an electronic device, including but not limited to a mobile phone, a tablet computer, a desktop computer, a notebook computer, a palm computer, a mobile internet device (mobile internet device, MID), a wearable device (e.g., a smart watch, a smart bracelet, etc.), and the like.
For each consensus node 101 in the consensus network 100, it may have a node identification corresponding thereto, and each consensus node in the consensus network 100 stores node identifications of other consensus nodes in the consensus network 100, so that the generated transaction block or the consensus result for the transaction block may be subsequently broadcasted to other consensus nodes in the consensus network 100 according to the node identifications of the other consensus nodes. For any one of the consensus nodes, a node identifier list may be maintained, where the node identifier list includes node identifiers of other consensus nodes in the consensus network 100, a consensus node name corresponding to the node identifiers, and the like. The node identifier may be an IP (Internet Protocol, protocol of interconnection between networks) address, or any other information that can be used to identify the node (e.g., factory identifier of the node). The data interaction between the consensus nodes 101 in the consensus network 100 may also be performed by other network interconnection manners.
Further, referring to fig. 2, fig. 2 is a block chain consensus architecture diagram according to an embodiment of the present application. The consensus network comprises a plurality of consensus nodes, any one of the consensus nodes in the consensus network can be used as an execution subject in the embodiment of the application, wherein when any one of the consensus nodes is used as the execution subject in the embodiment of the application, each step in the embodiment of the application can be executed to perform consensus on the transaction block. The plurality of consensus nodes included in the consensus network may include a local node and at least two consensus nodes, wherein the local node is any one of the plurality of consensus nodes, and the at least two consensus nodes belong to other consensus nodes except the local node among the plurality of consensus nodes in the consensus network.
Specifically, as shown in fig. 2, the plurality of consensus nodes included in the consensus network include a local node 201 and at least two consensus nodes, such as a consensus node 202a, a consensus node 202b, and a consensus node 202c, and the like, and data interaction can be performed between the consensus nodes. The local node 201 obtains a first-stage consensus result for the transaction block sent by at least two consensus nodes in a first-stage consensus period for consensus the transaction block, wherein the at least two consensus nodes belong to other consensus nodes except the local node 201 in the plurality of consensus nodes. After the local node 201 obtains the first-stage consensus result of the consensus node 202a, the first-stage consensus result of the consensus node 202b, and the first-stage consensus result of the consensus node 202c, the local node 201 uses the sum of the local consensus result of the transaction block and the number of the first-stage consensus results sent by at least two consensus nodes as the number of the first-stage voting results. When the number of first-stage voting results is smaller than the first number threshold, the local node 201 generates a second-stage local empty block for the transaction block, where the transaction data is empty, and the first number threshold is the minimum number of block voting success results of the consensus node required to be acquired for successful consensus of the transaction block, in other words, the transaction block can be added to the blockchain only when the number of block voting success results for the transaction block reaches the first number threshold. When the consensus node 202a determines that the transaction block is correct (i.e., approves the transaction block), a block voting success result for the transaction block is generated, and similarly, any one of the consensus nodes approving the transaction block in the consensus network generates a block voting success result for the transaction block.
In the second-stage consensus period, the local node 201 broadcasts the generated second-stage local empty block to other consensus nodes (i.e., the local node 201 sends the second-stage local empty block to the consensus nodes 202a, 202b and 202 c) in the consensus network, and obtains the second-stage consensus result sent by at least two consensus nodes. The local node 201 determines the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result, for example, when the number of second-stage consensus success results in the second-stage consensus results is greater than or equal to the first number threshold, determining the uplink result of the transaction block as the uplink success result; and when the sum of the number of the second-stage common-knowledge empty blocks in the second-stage local empty blocks and the second-stage common-knowledge result is larger than a second number threshold, determining that the uplink result of the transaction block is a uplink failure result. In this embodiment, the time used in the consensus process for one transaction block may be considered as one consensus period, where the consensus period includes a first-stage consensus period and a second-stage consensus period, the consensus process includes a first stage and a second stage, the maximum duration corresponding to the first stage is the first-stage consensus period, and the maximum duration corresponding to the second stage is the second-stage consensus period.
It is understood that the method provided in the embodiments of the present application may be performed by a computer device, that is, the local node 201 may be a computer device, and other common nodes in the common network other than the local node 201 may also be computer devices, where the computer devices include, but are not limited to, a terminal device or a server.
Further, referring to fig. 3, fig. 3 is a schematic view of a blockchain consensus scenario provided in an embodiment of the present application. As shown in fig. 3, the consensus node 3011 generates a first stage consensus result 3021 for a transaction block, and broadcasts the first stage consensus result 3021 to other consensus nodes in the consensus network; the consensus node 3012 generates a first stage consensus result 3022 for a transaction block, and broadcasts the first stage consensus result 3022 to other consensus nodes in the consensus network; the consensus node 3013 generates a first stage consensus result 3023 for a transaction block, and broadcasts the first stage consensus result 3023 to other consensus nodes in the consensus network; the consensus node 3014 generates a first stage consensus result 3024 for a transaction block, and broadcasts the first stage consensus result 3024 to other consensus nodes in the consensus network. The first-stage consensus results may be first-stage voting empty blocks (e.g., first-stage consensus result 3023), or may be block voting success results (e.g., first-stage consensus result 3021).
The local node 303 performs consensus on the acquired transaction block during the first phase consensus period, and generates a local consensus result 3031 for the transaction block. When the local node 303 obtains the first-stage consensus result for the transaction block sent by each consensus node, the local consensus result 3031 and the first-stage consensus results (such as the first-stage consensus results 3021 to 3024) are recorded as the first-stage voting result set 304, and the number of first-stage voting results corresponding to the first-stage voting result set 304 is determined. The local node 303 compares the number of first-stage voting results with a first-stage threshold 305, and if the number of first-stage voting results is smaller than the first-stage threshold 305, generates a second-stage local empty block 306, which is a block in which the transaction data is empty.
The local node 303 broadcasts the second phase local null block 306 to at least two of the consensus nodes (including the consensus node 3011, the consensus node 3012, the consensus node 3013, the consensus node 3014, etc.) during the second phase consensus period. The consensus node 3011 obtains a first-stage consensus result sent by the local node 303, the consensus node 3012, the consensus node 3013, the consensus node 3014 and the like in a first-stage consensus period, generates a second-stage consensus result 3071 according to the first-stage consensus result obtained by the consensus node 3011, and broadcasts the second-stage consensus result 3071 to other consensus nodes; the consensus node 3012 obtains a first-stage consensus result sent by the local node 303, the consensus node 3011, the consensus node 3013, the consensus node 3014 and the like in a first-stage consensus period, generates a second-stage consensus result 3072 according to the first-stage consensus result obtained by the consensus node 3012, and broadcasts the second-stage consensus result 3072 to other consensus nodes; the consensus node 3013 obtains a first-stage consensus result sent by the local node 303, the consensus node 3011, the consensus node 3012, the consensus node 3014 and the like in a first-stage consensus period, generates a second-stage consensus result 3073 according to the first-stage consensus result obtained by the consensus node 3013, and broadcasts the second-stage consensus result 3073 to other consensus nodes; the consensus node 3014 obtains the first-stage consensus result sent by the local node 303, the consensus node 3011, the consensus node 3012, the consensus node 3013, and the like in the first-stage consensus period, generates a second-stage consensus result 3074 according to the first-stage consensus result obtained by the consensus node 3014, and broadcasts the second-stage consensus result 3074 to other consensus nodes.
The local node 303 records the second-stage local empty block 306 and the second-stage consensus result sent by at least two consensus nodes (including the consensus node 3011, the consensus node 3012, the consensus node 3013, the consensus node 3014, and the like) as a second-stage voting result set 308, and determines the uplink result of the transaction block according to the second-stage voting result set 308. For example, the second-stage consensus result of the consensus node 3011 is a second-stage consensus success result, the second-stage consensus result of the consensus node 3012 is a second-stage consensus success result, the second-stage consensus result of the consensus node 3013 is a second-stage consensus success result, the second-stage consensus result of the consensus node 3014 is a second-stage consensus empty block, and the number of second-stage consensus success results included in the second-stage voting result set 308 is 3, where the first number threshold is 3, and the number of second-stage consensus success results is equal to the first number threshold, and it is determined that the uplink result of the transaction block is a uplink success result; the second stage consensus result of the consensus node 3011 is a second stage consensus empty block, the second stage consensus result of the consensus node 3012 is a second stage consensus empty block, the second stage consensus result of the consensus node 3013 is a second stage consensus success result, the second stage consensus result of the consensus node 3014 is a second stage consensus success result, and the number of second stage consensus empty blocks included in the second stage voting result set 308 is 3 (including a second stage local empty block), where the second number threshold is 2, and the number of second stage consensus empty blocks is greater than the second number threshold, and it is determined that the uplink result of the transaction block is a uplink failure result.
When any one of the consensus nodes (such as the consensus node 3011, the consensus node 3012, the consensus node 3013, or the consensus node 3014) in the consensus network performs the blockchain consensus process in the embodiments of the present application, the performed steps may be referred to the specific description of the local node 303. At this time, the common node as the execution subject may be regarded as a local node.
According to the method and the device for identifying the transaction block, accuracy of the identification result of the transaction block can be improved through the identification of the transaction block in two stages, when the identification is carried out on the transaction block, the first-stage identification result is obtained in the first-stage identification period, the second-stage identification result is obtained in the second-stage identification period, time limitation exists in the two stages, when the identification is carried out on the transaction block, abnormal conditions occur, and therefore the linking-up result of the transaction block cannot be determined, the identification process is not interrupted, an empty block is generated, and the empty block is used as a local identification result of the corresponding stage, so that a local node can continue to execute the subsequent identification process, and therefore efficiency of block chain identification is improved. In the embodiment of the application, each consensus node in the consensus network can be used as a local node to execute the step of block chain consensus in the embodiment of the application, so that the consistency of the consensus result of each consensus node and the consistency and safety of stored data are ensured.
Further, referring to fig. 4, fig. 4 is a flowchart of a blockchain consensus method according to an embodiment of the present application. As shown in fig. 4, the above-mentioned computer device is used as an execution body, and the computer device refers to a local node in the embodiment of the present application, and the blockchain consensus process includes the following steps:
step S401, in the first stage consensus period, a first stage consensus result for the transaction block sent by at least two consensus nodes is obtained.
Specifically, the local node obtains a first-stage consensus result for the transaction block sent by at least two consensus nodes in a first-stage consensus period. Wherein the first phase consensus period belongs to a consensus period for the transaction block, and the consensus period for the transaction block can be regarded as a time period for consensus for the transaction block. The first-stage consensus result obtained by the local node comprises a consensus result sent by any one or more of the at least two consensus nodes for a transaction block. For example, when the local node is node a and the at least two consensus nodes include node B, node C and node D, and the local node obtains the first-stage consensus result for the transaction block sent by the at least two consensus nodes, the node B does not send the first-stage consensus result for the transaction block or loses the first-stage consensus result in the sending process, so that the node a obtains the first-stage consensus result sent by the node C and the node D. The first-stage consensus result may be a block voting success result, or a first-stage voting empty block, etc., where the block voting success result is used to indicate that the corresponding consensus node verifies the transaction block, and the first-stage voting empty block is used to indicate that the corresponding consensus node does not acquire the transaction block or fails to verify the transaction block.
Specifically, the node B, the node C, and the node D included in the at least two common nodes are taken as examples. The node B generates a first-stage consensus result 1 for the transaction block, and broadcasts the first-stage consensus result 1 to other consensus nodes except the node B; the node C generates a first-stage consensus result 2 for the transaction block, and broadcasts the first-stage consensus result 2 to other consensus nodes except the node C; node D generates a first stage consensus result 3 for the transaction block and broadcasts the first stage consensus result 3 to other consensus nodes other than node D. And the local node acquires a first-stage consensus result for the transaction block sent by at least two consensus nodes in the first-stage consensus period, and when the first-stage consensus period is finished, the local node acquires a first-stage consensus result 2 sent by the node C and does not continuously acquire the first-stage consensus result of the node B or the node D.
Step S402, determining the number of first-stage voting results according to the local consensus result and the first-stage consensus result for the transaction block.
Specifically, the local node generates a local consensus result for the transaction block, counts the sum of the local consensus result and the number of first-stage consensus results for the transaction block, and determines the sum of the local consensus result and the number of first-stage consensus results as the number of first-stage voting results. The first-stage voting result number is used for representing the total number of first-stage consensus results (including the local consensus results generated by the local node) acquired by the local node in a first-stage consensus period, and the first-stage voting result number can be used for representing the effective number of votes acquired by the local node for a transaction block.
In step S403, if the number of voting results in the first stage is smaller than the first number threshold, a local empty block in the second stage is generated.
Specifically, the local node compares the number of the first-stage voting results with a first number threshold, and if the number of the first-stage voting results is smaller than the first number threshold, a second-stage local empty block is generated, wherein the second-stage local empty block is a block with empty transaction data, such as a block with empty block header but not empty block header, or a block with empty block body and block header. The first quantity threshold is determined by a consensus algorithm and a consensus node included in a consensus network and is used for representing the minimum quantity of block voting success results, which are required to be acquired, of the transaction block consensus. For example, assuming that the consensus algorithm is bayer 2/3, the consensus network includes 4 consensus nodes, the first number threshold is determined to be 3 by the consensus algorithm and the consensus network; in other words, in the first-stage consensus period, when the block voting success result for the transaction block generated by three or more consensus nodes is obtained, the first-stage consensus of the transaction block is considered to be successful; and in the second-stage consensus period, when the second-stage consensus success result generated by three or more consensus nodes is obtained, the second-stage consensus of the transaction block is considered to be successful, and the transaction block can be uplink.
When the number of the first-stage voting results is smaller than the first-stage threshold, the number of the valid votes acquired by the local node can be considered to be less than the minimum number of the block voting success results required when the transaction block consensus passes. Therefore, when the number of the voting results in the first stage is smaller than the first number threshold, the total number of the voting success results of the blocks must be smaller than the first number threshold, that is, the condition that the transaction block passes through the first stage consensus is not met, the local node can consider that the transaction block fails to be consensus in the first stage, and a second stage local empty block is generated, wherein the second stage local empty block is used for indicating that the local node fails to consensus the transaction block in the first stage. Wherein the second stage local empty block may be considered a second stage local consensus result of the local node.
And step S404, broadcasting the second-stage local empty block to at least two consensus nodes in a second-stage consensus period, and acquiring a second-stage consensus result sent by the at least two consensus nodes.
Specifically, the local node broadcasts the second-stage local empty block to at least two consensus nodes in the second-stage consensus period, and obtains a second-stage consensus result sent by the at least two consensus nodes. The second-stage consensus period belongs to the consensus period for the transaction block, that is, the first-stage consensus period and the second-stage consensus period both belong to the consensus period for the transaction block, and the first-stage consensus period is earlier than the second-stage consensus period. The process of generating the second-stage consensus result by each of the at least two consensus nodes is the same as the process of generating the second-stage local consensus result by the local node, specifically, refer to step S403, where after any one of the at least two consensus nodes generates the corresponding second-stage consensus result, the second-stage consensus result generated by the consensus node is broadcast to other consensus nodes in the consensus network. The local node obtains second-stage consensus results sent by at least two consensus nodes.
Step S405, determining the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result.
Specifically, the local node determines the uplink result of the transaction block according to the second-stage local empty block and the obtained second-stage consensus result. The second stage local empty block is used for indicating that the local node fails to verify the transaction block in the second stage consensus period. The local node detects whether the second-stage local empty block and the second-stage consensus result meet the consensus condition, and when the second-stage local empty block and the second-stage consensus result meet the consensus condition, the uplink result of the transaction block is determined to be an uplink successful result; and when the second-stage local empty block and the second-stage consensus result do not meet the consensus condition, determining that the uplink result of the transaction block is the uplink failure result. The consensus condition can be determined according to a consensus algorithm and a consensus network, wherein the consensus algorithm can be Bayesian family 2/3, and the consensus condition is that the consensus nodes exceeding 2/3 in the consensus network pass the verification of the transaction block.
According to the embodiment of the application, through the block chain consensus process, a first-stage consensus result sent by at least two consensus nodes and aiming at a transaction block is obtained in a first-stage consensus period; determining the number of first-stage voting results according to the local consensus result, the first-stage consensus result and the first-stage consensus result for the transaction block; if the number of the voting results in the first stage is smaller than a first number threshold, generating a local empty block in the second stage; in the second-stage consensus period, broadcasting a second-stage local empty block to at least two consensus nodes, and acquiring a second-stage consensus result sent by the at least two consensus nodes; and determining the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result. The obtained transaction block is subjected to twice consensus, and each consensus stage limits time, namely a first-stage consensus period and a second-stage consensus period, so that the longest duration required by twice consensus is an upper limit in each consensus period of the transaction block, and therefore, even if abnormal conditions occur in the consensus process of the transaction block, the local node cannot interrupt the consensus process and generate empty blocks of corresponding stages, and the subsequent consensus process is continuously executed based on the empty blocks, so that the time loss is reduced, and the efficiency of block chain consensus is improved.
Further, referring to fig. 5, fig. 5 is a schematic block chain consensus flowchart in accordance with an embodiment of the present application. As shown in fig. 5, in the first-stage consensus period, the local node acquires the transaction block, if the transaction block is not acquired in the first-stage consensus period, step S501 is executed, and if the transaction block is acquired in the first-stage consensus period, step S502 is executed, which specifically includes the following steps:
in step S501, if the transaction block is not acquired in the first stage consensus period, a first stage local empty block is generated as a local consensus result.
Specifically, in the first stage consensus period, the transaction block is acquired, if the transaction block is not acquired in the first stage consensus period, in other words, the local node still does not acquire the transaction block at the end of the first stage consensus period, the local node generates a first stage local empty block, uses the first stage local empty block as a local consensus result, broadcasts the local consensus result to at least two consensus nodes, and executes step S504 to acquire the first stage consensus result for the transaction block sent by the at least two consensus nodes.
Specifically, referring to fig. 6, fig. 6 is a schematic view of a first-stage local consensus result generation scenario provided in an embodiment of the present application. As shown in fig. 6, one of the consensus nodes in the consensus network acquires transaction data, the consensus node is referred to as a block generation node 6011, the block generation node 6011 generates a transaction block 602 according to the transaction data, and the transaction block 602 is broadcast to the consensus nodes in the consensus network except the block generation node 6011, including the consensus node 6012, the consensus node 6013, the consensus node 6014, and the like. Taking the consensus node 6012 as an example, the consensus node 6012 is referred to as a local node, the consensus node 6012 does not acquire the transaction block 602 transmitted by the block generating node 6011 in the first-stage consensus period, generates the first-stage local empty block 603, and uses the first-stage local empty block 603 as a local consensus result, where the first-stage local empty block 603 is a block with null transaction data. The consensus node 6012 broadcasts the local consensus result to other nodes in the consensus network, including a block generating node 6011, a consensus node 6013, a consensus node 6014, and the like.
Step S502, if the transaction block is obtained in the first stage consensus period, the transaction block is verified.
Specifically, if the local node acquires the transaction block in the first stage consensus period, the transaction block is verified, specifically, the transaction data in the block body of the transaction block and the block header data in the block header are verified. For example, assuming that the block header of the transaction block includes a block height, a time stamp, a block header hash value, etc., the local node obtains a preceding block with the largest time stamp from the blockchain, obtains a preceding block height of the preceding block, and considers the block height of the transaction block to be correct when the preceding block height is smaller than the block height and the difference value between the preceding block height and the preceding block height is 1; and acquiring transaction data in a block in the transaction block, generating a hash value according to the data in the block head of the transaction block, and if the hash value is the same as the block head hash value, considering that the block head hash value of the transaction block is correct. The local block verifies the data in the block head of the transaction block and the transaction data in the block body, and if the data in the block head and the transaction data in the block body are correct, the transaction block is verified to pass; if the data in the block head and the transaction data in the block body have error data, determining that the verification of the transaction block fails.
Step S503, generating a local consensus result according to the verification result.
Specifically, if the transaction block is verified, generating a block voting success result aiming at the transaction block, taking the block voting success result aiming at the transaction block as a local consensus result, and broadcasting the local consensus result to at least two consensus nodes; if the transaction block verification is not passed, a first-stage local empty block is generated, the first-stage local empty block is used as a local consensus result, and the local consensus result is broadcast to at least two consensus nodes. The block voting success result is used for indicating that the local node approves the transaction block in the first stage consensus period; the first stage local empty block is used for indicating that the local node does not recognize the transaction block or does not acquire the transaction block in the first stage consensus period.
Step S504, a first-stage consensus result sent by at least two consensus nodes for a transaction block is obtained.
Specifically, the local node obtains first-stage consensus results for the transaction block sent by at least two consensus nodes, wherein the process of generating the first-stage consensus results for the transaction block by each consensus node is the same as the process of generating the first-stage local consensus results by the local node. When the consensus node is a block generation node, the block generation node approves the transaction block and generates a block voting success result aiming at the transaction block as a first-stage consensus result of the block generation node because the transaction block is generated by the block generation node.
Step S505, determining the number of voting results in the first stage according to the local consensus result and the consensus result in the first stage.
Specifically, the sum of the number of the local consensus results and the number of the first-stage consensus results is used as the number of the first-stage voting results. For example, the consensus network includes 6 consensus nodes, namely a consensus node a, a consensus node B, a consensus node C, a consensus node D, a consensus node E and a consensus node F, where the consensus node a is assumed to be a local node, the local node obtains a first-stage consensus result 1 of the consensus node B and a first-stage consensus result 2 of the consensus node C, and the local node counts the number of the local consensus results and the first-stage consensus results to obtain a first-stage voting result number of 3, including a local consensus result, a first-stage consensus result 1 and a first-stage consensus result 2.
Step S506, comparing the number of the voting results in the first stage with a first number threshold value, and generating a local consensus result in the second stage.
Specifically, a first quantity threshold is obtained, the quantity of voting results in the first stage is compared with the first quantity threshold, and a local consensus result in the second stage is generated according to the comparison result. The first quantity threshold is determined according to a consensus algorithm and a consensus network, and is used for representing the number of consensus nodes of a required approved transaction block when the transaction block can be uplink. For example, taking the consensus network in step S505 as an example, the consensus network includes 6 consensus nodes, which are respectively a consensus node a, a consensus node B, a consensus node C, a consensus node D, a consensus node E, and a consensus node F, where the consensus node a is assumed to be a local node, and when the consensus algorithm is a bayer 2/3, a first number threshold is obtained as 4.
Specifically, a second-stage local consensus result generation process is as follows: if the number of the voting results in the first stage is smaller than the first number threshold, generating a second-stage local empty block, and taking the second-stage local empty block as a second-stage local consensus result. For example, a first-stage consensus result 1 of the consensus node B and a first-stage consensus result 2 of the consensus node C are obtained, and the local node counts the number of local consensus results and first-stage consensus results to obtain a first-stage voting result number of 3, including the local consensus result, the first-stage consensus result 1 and the first-stage consensus result 2. The number of the first-stage voting results 3 is smaller than the first number threshold 4, and the number of the first-stage voting success results is necessarily smaller than the first number threshold 4, the local node generates a second-stage local empty block, and the second-stage local empty block is used as a second-stage local consensus result to indicate that the local node approves the transaction block in the second stage.
Another second stage local consensus result generation process; if the number of the first-stage voting results is greater than or equal to a first number threshold, counting the number of first-stage voting empty blocks in the first-stage consensus result; the first-stage voting empty block is generated by a consensus node which detects that the transaction block does not meet the consensus condition in at least two consensus nodes. Determining the number of first empty blocks according to the local consensus result and the number of first-stage voting empty blocks; and if the number of the first empty blocks is larger than a second number threshold, generating second-stage local empty blocks, taking the second-stage local empty blocks as second-stage local consensus results, and broadcasting the second-stage local empty blocks into at least two consensus nodes.
When the first empty block number is determined, the local node detects the local consensus result, and if the local consensus result is a block voting success result aiming at a transaction block, the first-stage voting empty block number is determined as the first empty block number; if the local consensus result is the first stage local empty block, taking the sum of the number of the first stage local empty block and the first stage voting empty block as the first empty block number.
Yet another second stage local consensus result generation process: if the number of the first-stage voting results is larger than or equal to a first number threshold, counting the number of the first-stage voting success results in the first-stage consensus results; the first stage voting success result is generated by the consensus node which detects that the transaction block meets the consensus condition in the at least two consensus nodes. Determining the number of first voting success results according to the number of the local consensus results and the number of the first voting success results; if the first voting success number is greater than or equal to the first number threshold, generating a second-stage local consensus success result, taking the second-stage local consensus success result as a second-stage local consensus result of the local node, and broadcasting the second-stage local consensus success result to at least two consensus nodes; if the number of successful votes is smaller than the first number threshold, a second-stage local empty block is generated, the second-stage local empty block is used as a second-stage local consensus result, and the second-stage local consensus result is broadcast to at least two consensus nodes.
When the first voting success number is determined, if the local consensus result is a block voting success result aiming at the transaction block, taking the sum of the local consensus result and the first-stage voting success result as the first voting success number; if the local consensus result is the first stage local empty block, determining the number of the first stage voting success results as the first voting success number.
Specifically, when the number of the first empty blocks is smaller than or equal to the second number threshold, the first voting success number can be obtained, if the first voting success number is larger than or equal to the first number threshold, a second-stage local consensus success result is generated, and the second-stage local consensus success result is used as a second-stage local consensus result of the local node; if the number of successful votes is smaller than the first number threshold, generating a second-stage local empty block, and taking the second-stage local empty block as a second-stage local consensus result.
The sum of the first number threshold and the second number threshold is the total number of consensus nodes included in the consensus network, so when the number of the first empty blocks is greater than the second number threshold, the first voting success number is necessarily smaller than the first number threshold, and the local node can determine that the consensus of the transaction block in the first stage is not passed, and generate a second stage local empty block. For example, the consensus network comprises 6 consensus nodes, the consensus algorithm is Bayesian 2/3, and the first number threshold is determined to be 4, and the second number threshold is determined to be 2.
Step S507, obtaining a second-stage consensus result sent by at least two consensus nodes.
Specifically, a second-stage consensus result sent by at least two consensus nodes is obtained. The process of generating the corresponding second-stage consensus result by each consensus node is the same as the process of generating the second-stage local consensus result by the local node in step S506, and will not be described herein.
Step S508, determining the uplink result of the transaction block according to the second-stage local consensus result and the second-stage consensus result.
Specifically, the uplink result of the transaction block is determined according to the second-stage local consensus success result and the second-stage consensus result.
Wherein, a uplink result determining process: when the second-stage local consensus result of the local node is a second-stage local empty block, taking the number of second-stage consensus success results in the second-stage consensus result as a second voting success number; and when the second-stage local consensus result of the local node is a second-stage local consensus success result, taking the sum of the second-stage local consensus result and the second-stage consensus success result as a second voting success number. If the second voting success number is greater than or equal to the first number threshold, uploading the transaction block to a block chain, and determining that the uplink result of the transaction block is an uplink success result; if the second voting success number is smaller than the first number threshold, deleting the transaction block, and determining that the uplink result of the transaction block is the uplink failure result.
Another uplink result determination process: when the second-stage local consensus result of the local node is a second-stage local empty block, counting the number of the second-stage consensus empty blocks in the second-stage local consensus result, and taking the sum of the number of the second-stage local empty blocks and the number of the second-stage consensus empty blocks as the number of the second empty blocks; and when the second-stage local consensus result of the local node is a second-stage local consensus success result, the number of second-stage consensus empty blocks is used as a second empty block number. If the second empty block number is greater than the second number threshold, deleting the transaction block, and determining that the uplink result of the transaction block is the uplink failure result.
Yet another uplink result determination procedure: determining the number of voting results in the second stage according to the consensus results of the local empty blocks in the second stage and the second stage; if the number of the voting results in the second stage is smaller than the first number threshold, deleting the transaction block, and determining that the uplink result of the transaction block is the uplink failure result.
Specifically, referring to fig. 7, fig. 7 is a schematic diagram of a uplink result determination scenario provided in an embodiment of the present application. As shown in fig. 7, the local node obtains a second-stage local consensus result and a second-stage consensus result sent by at least two consensus nodes, where the second-stage local consensus result includes a second-stage consensus empty block 7011, a second-stage consensus success result 7012, a second-stage consensus empty block 7013, a second-stage consensus success result 7014, and the like, where the second-stage local empty block is equivalent to a second-stage consensus empty block for other consensus nodes, and the second-stage local consensus success result is equivalent to a second-stage consensus success result for other consensus nodes.
The local node may count the number of second-stage consensus success results (including second-stage consensus success result 7012, second-stage consensus success result 7014, second-stage consensus success result 701m, etc.), where m is a positive integer as the second voting success number m. Deleting the transaction block 703 when the second voting success number m is smaller than the first number threshold, and determining that the uplink result of the transaction block is a uplink failure result; when the second number of votes, m, is greater than or equal to the first number threshold, transaction block 703 is added to blockchain 704, and the uplink result of the transaction block is determined to be an uplink success result.
The local node may also count the number of second-stage common-air blocks (including second-stage common-air block 7011, second-stage common-air block 7013, and second-stage common-air block 701 n), where n is a positive integer as the second-air block number n. When the second number n of empty blocks is greater than the second number threshold, the transaction block 703 is deleted, and the uplink result of the transaction block is determined to be the uplink failure result. When the second number n of empty blocks is smaller than or equal to a second number threshold, a second voting success number m is acquired, the second voting success number m is compared with the first number threshold, and when the second voting success number m is smaller than the first number threshold, the transaction block 703 is deleted, and the uplink result of the transaction block is determined to be a uplink failure result; when the second number of votes, m, is greater than or equal to the first number threshold, a transaction block 703 is added to the blockchain 704, and the uplink result for that transaction block is determined to be a uplink success result.
In step S509, when the uplink result is the uplink failure result, the block generation authority of the block generation node generating the transaction block is limited.
Specifically, if the uplink result of the transaction block is the uplink failure result, a block generation node of the transaction block is obtained. Adding the block generating node into the authority limit node set; the set of rights-limiting nodes includes consensus nodes that do not have rights to generate the block. And acquiring the storage time length of the block generation node in the authority limit set, deleting the block generation node in the authority limit set if the storage time length is longer than the authority limit time, and recovering the generation block authority of the block generation node. Optionally, when the local node obtains a new transaction block, obtaining a generation node and a permission limit node set of the new transaction block, if the generation node of the new transaction block belongs to the permission limit node set, sending a block generation exception message to the generation node of the new transaction block so as to inform the generation node of the new transaction block that the generation node of the new transaction block temporarily has no generation block permission.
In the embodiment of the application, a first-stage consensus result sent by at least two consensus nodes and aiming at a transaction block is obtained in a first-stage period through a local node; verifying the transaction block, and generating a local consensus result according to the verification result; and determining the number of the first-stage voting results according to the local consensus result and the first-stage consensus result. When the number of voting results in the first stage is smaller than a first number threshold value, generating a local empty block in the second stage; and when the number of the first-stage voting results is greater than or equal to a first number threshold, generating a second-stage local consensus result according to the first-stage voting success result or the first-stage voting empty block in the first-stage consensus result and the local consensus result. And determining the uplink result of the transaction block according to the local consensus result of the second stage and the second-stage consensus results sent by the at least two consensus nodes. Through the process, the transaction block is subjected to two-stage consensus, the first stage directly carries out consensus on the transaction block, and the second stage carries out consensus on the consensus result of each consensus node in the first stage, so that the safety and reliability of data of the transaction block are improved. Meanwhile, the two phases of consensus for the transaction block have time limitation, so that when the consensus result for the transaction block cannot be determined, the consensus process for the transaction block is not interrupted, a null block is generated, and the null block is used as the consensus result for the transaction block so as to continuously execute the subsequent consensus process, thereby reducing the time consumed by block chain consensus and improving the efficiency of block chain consensus.
Further, referring to fig. 8, fig. 8 is a schematic diagram of a blockchain consensus device according to an embodiment of the present application. The blockchain consensus device may be a computer program (including program code) running in a computer device, for example, the blockchain consensus device is an application software; the device can be used for executing corresponding steps in the method provided by the embodiment of the application. As shown in fig. 8, the blockchain consensus device 80 may be used in the computer device in the embodiment corresponding to fig. 4 or fig. 5, and specifically, the blockchain consensus device 80 may include: the system comprises a consensus acquisition module 11, a vote number determination module 12, a first empty block generation module 13, a first consensus interaction module 14 and a uplink result determination module 15.
The consensus acquisition module 11 is configured to acquire a first-stage consensus result for a transaction block sent by at least two consensus nodes in a first-stage consensus period;
a vote number determining module 12, configured to determine a first-stage vote number according to the local consensus result for the transaction block and the first-stage consensus result;
a first empty block generating module 13, configured to generate a second stage local empty block if the number of voting results in the first stage is less than a first number threshold; the local empty block in the second stage is a block with empty transaction data;
The first consensus interaction module 14 is configured to broadcast, in a second-stage consensus period, the second-stage local empty block to the at least two consensus nodes, and obtain a second-stage consensus result sent by the at least two consensus nodes; the first-stage consensus period and the second-stage consensus period belong to the consensus period for the transaction block, and the first-stage consensus period is earlier than the second-stage consensus period;
the uplink result determining module 15 is configured to determine an uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result.
Wherein, the device 80 further comprises:
a null block statistics module 16, configured to, if the number of the first-stage voting results is greater than or equal to the first number threshold, count the number of first-stage voting null blocks in the first-stage consensus result; the first-stage voting empty block is generated by a consensus node which detects that the transaction block does not meet the consensus condition in the at least two consensus nodes;
the empty block statistics module 16 is further configured to determine a first number of empty blocks according to the local consensus result and the first number of empty blocks voted in the first stage;
And a second empty block generating module 17, configured to generate the second stage local empty block if the number of the first empty blocks is greater than a second number threshold.
Wherein, in the aspect of determining the first number of empty blocks according to the local consensus result and the number of empty blocks in the first stage, the empty block statistics module 16 includes:
a first number determining unit 161 configured to determine the number of first-stage voting empty blocks as the first number of empty blocks if the local consensus result is a block voting success result for the transaction block;
the first number determining unit 161 is further configured to, if the local consensus result is a first-stage local empty block, set a sum of the number of first-stage local empty blocks and the number of first-stage voting empty blocks as the first empty block number.
Wherein, the device 80 further comprises:
the second consensus interaction module 18 is configured to generate the first-stage local empty block if the transaction block is not acquired in the first-stage consensus period, use the first-stage local empty block as the local consensus result, and broadcast the local consensus result to the at least two consensus nodes.
Wherein, the device 80 further comprises:
a block verification module 19, configured to verify the transaction block if the transaction block is acquired in the first stage consensus period;
a first result generating module 20, configured to generate a block voting success result for the transaction block if the transaction block verification passes, take the block voting success result for the transaction block as the local consensus result, and broadcast the local consensus result to the at least two consensus nodes;
and a third empty block generating module 21, configured to generate the first-stage local empty block if the transaction block verification is not passed, and broadcast the local consensus result to the at least two consensus nodes with the first-stage local empty block as the local consensus result.
Wherein, the device 80 further comprises:
a success statistics module 22, configured to, if the number of the first-stage voting results is greater than or equal to the first number threshold, count the number of first-stage voting success results in the first-stage consensus result; the successful voting result in the first stage is generated by the consensus node which detects that the transaction block meets the consensus condition in the at least two consensus nodes;
The success statistics module 22 is further configured to determine a first number of votes success according to the local consensus result and the number of votes success at the first stage;
a second result generating module 23, configured to generate a second-stage local consensus success result if the first number of votes is greater than or equal to the first number threshold, broadcast the second-stage local consensus success result to the at least two consensus nodes, and obtain a second-stage consensus result sent by the at least two consensus nodes;
the uplink result determining module 15 is configured to determine the uplink result of the transaction block according to the second-stage local consensus success result and the second-stage consensus result.
Wherein, in determining the first number of voting success according to the number of the local consensus result and the first-stage voting success result, the success statistics module 22 includes:
a second number determining unit 221, configured to, if the local consensus result is a block voting success result for the transaction block, set a sum of the local consensus result and the number of first-stage voting success results as the first voting success number;
The second number determining unit 221 is further configured to determine, if the local consensus result is a first-stage local empty block, the number of successful voting results in the first stage as the first successful voting number.
Wherein the uplink-result determining module 15 includes:
a third number determining unit 151 configured to determine, as a second voting success number, the number of second-stage consensus success results among the second-stage consensus results;
a uplink success determining unit 152, configured to upload the transaction block to a blockchain if the second number of votes success is greater than or equal to the first number threshold, and determine that the uplink result of the transaction block is an uplink success result;
the uplink failure determining unit 153 is configured to delete the transaction block if the second number of successful votes is smaller than the first number threshold, and determine that the uplink result of the transaction block is the uplink failure result.
Wherein the uplink-result determining module 15 includes:
a block number statistics unit 154, configured to count the number of second-stage consensus blocks in the second-stage consensus result;
the number of empty blocks statistics unit 154 is further configured to use a sum of the number of the second-stage local empty blocks and the second-stage consensus empty blocks as a second number of empty blocks;
The uplink failure determining unit 153 is further configured to delete the transaction block if the second number of empty blocks is greater than a second number threshold, and determine that the uplink result of the transaction block is the uplink failure result.
Wherein the uplink-result determining module 15 includes:
a voting result statistics unit 155, configured to determine the number of second-stage voting results according to the second-stage local empty block and the second-stage consensus result;
the uplink failure determining unit 153 is further configured to delete the transaction block if the number of voting results in the second stage is smaller than the first number threshold, and determine that the uplink result of the transaction block is the uplink failure result.
Wherein, the device 80 further comprises:
a generating node obtaining module 24, configured to obtain a block generating node of the transaction block if the uplink result of the transaction block is a uplink failure result;
a node adding module 25, configured to add the block generating node to a permission limiting node set; the authority limit node set comprises consensus nodes without generating block authorities;
and the permission updating module 26 is configured to obtain a storage time length of the block generating node in the permission limit set, delete the block generating node in the permission limit set, and restore the generated block permission of the block generating node if the storage time length is longer than the permission limit time.
The embodiment of the application describes a block chain consensus device, wherein the device obtains a first-stage consensus result aiming at a transaction block and sent by at least two consensus nodes in a first-stage period through a local node; verifying the transaction block, and generating a local consensus result according to the verification result; and determining the number of the first-stage voting results according to the local consensus result and the first-stage consensus result. When the number of voting results in the first stage is smaller than a first number threshold value, generating a local empty block in the second stage; and when the number of the first-stage voting results is greater than or equal to a first number threshold, generating a second-stage local consensus result according to the first-stage voting success result or the first-stage voting empty block in the first-stage consensus result and the local consensus result. And determining the uplink result of the transaction block according to the local consensus result of the second stage and the second-stage consensus results sent by the at least two consensus nodes. Through the process, the transaction block is subjected to two-stage consensus, the first stage directly carries out consensus on the transaction block, and the second stage carries out consensus on the consensus result of each consensus node in the first stage, so that the safety and reliability of data of the transaction block are improved. Meanwhile, the two phases of the block consensus are limited in time, so that the block consensus process is not interrupted when the consensus result of the block can not be determined, the time consumed by the block chain consensus is reduced, and the block chain consensus efficiency is improved.
Referring to fig. 9, fig. 9 is a schematic structural diagram of a computer device according to an embodiment of the present application. As shown in fig. 9, a computer device 900 in an embodiment of the present application may include: one or more processors 901, memory 902, and input-output interfaces 903. The processor 901, the memory 902, and the input/output interface 903 are connected via a bus 904. The memory 902 is used for storing a computer program, the computer program comprises program instructions, and the input-output interface 903 is used for data interaction between the consensus nodes in the consensus network; the processor 901 is configured to execute program instructions stored in the memory 902, and perform the following operations:
in a first-stage consensus period, acquiring a first-stage consensus result aiming at a transaction block and sent by at least two consensus nodes;
determining the number of first-stage voting results according to the local consensus result for the transaction block and the first-stage consensus result;
if the number of the voting results in the first stage is smaller than a first number threshold, generating a local empty block in the second stage; the local empty block in the second stage is a block with empty transaction data;
in a second-stage consensus period, broadcasting the second-stage local empty block to the at least two consensus nodes to obtain a second-stage consensus result sent by the at least two consensus nodes; the first-stage consensus period and the second-stage consensus period belong to the consensus period for the transaction block, and the first-stage consensus period is earlier than the second-stage consensus period;
And determining the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result.
In some possible embodiments, the processor 901 may be a central processing unit (central processing unit, CPU), which may also be other general purpose processors, digital signal processors (digital signal processor, DSP), application specific integrated circuits (application specific integrated circuit, ASIC), off-the-shelf programmable gate arrays (field-programmable gate array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 902 may include read only memory and random access memory and provides instructions and data to the processor 901 and the input output interface 903. A portion of the memory 902 may also include non-volatile random access memory. For example, the memory 902 may also store information of device type.
In a specific implementation, the computer may execute, through each functional module built in the computer, an implementation provided by each step in fig. 4 or fig. 5, and in particular, the implementation provided by each step in fig. 4 or fig. 5 may be referred to, which is not described herein again.
Embodiments of the present application provide a computer device, comprising: the processor, the input/output interface and the memory acquire the computer instructions in the memory through the processor, execute the steps of the method shown in fig. 4 or fig. 5, and perform the blockchain consensus operation. The processor, through computer instructions in the memory, performs the steps of: in a first stage period, a first stage consensus result sent by at least two consensus nodes and aiming at a transaction block is obtained; verifying the transaction block, and generating a local consensus result according to the verification result; and determining the number of the first-stage voting results according to the local consensus result and the first-stage consensus result. When the number of voting results in the first stage is smaller than a first number threshold value, generating a local empty block in the second stage; and when the number of the first-stage voting results is greater than or equal to a first number threshold, generating a second-stage local consensus result according to the first-stage voting success result or the first-stage voting empty block in the first-stage consensus result and the local consensus result. And determining the uplink result of the transaction block according to the local consensus result of the second stage and the second-stage consensus results sent by the at least two consensus nodes. Through the process, the transaction block is subjected to two-stage consensus, the first stage directly carries out consensus on the transaction block, and the second stage carries out consensus on the consensus result of each consensus node in the first stage, so that the safety and reliability of data of the transaction block are improved. Meanwhile, the two phases of the block consensus are limited in time, so that the block consensus process is not interrupted when the consensus result of the block can not be determined, the time consumed by the block chain consensus is reduced, and the block chain consensus efficiency is improved.
The embodiment of the present application further provides a computer readable storage medium, where the computer readable storage medium stores a computer program, where the computer program includes program instructions, when executed by the processor, may implement the blockchain consensus method provided by each step in fig. 4 or fig. 5, and specifically refer to the implementation manner provided by each step in fig. 4 or fig. 5, which is not described herein again. In addition, the description of the beneficial effects of the same method is omitted. For technical details not disclosed in the embodiments of the computer-readable storage medium according to the present application, please refer to the description of the method embodiments of the present application. As an example, the program instructions may be deployed to be executed on one computer device or on multiple computer devices at one site or distributed across multiple sites and interconnected by a communication network.
The computer readable storage medium may be a blockchain consensus device provided in any of the foregoing embodiments or an internal storage unit of the computer, such as a hard disk or a memory of the computer. The computer readable storage medium may also be an external storage device of the computer, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a flash card (flash card) or the like, which are provided on the computer. Further, the computer-readable storage medium may also include both internal storage units and external storage devices of the computer. The computer-readable storage medium is used to store the computer program and other programs and data required by the computer. The computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.
The terms first, second and the like in the description and in the claims and drawings of the embodiments of the present application are used for distinguishing between different objects and not for describing a particular sequential order. Furthermore, the term "include" and any variations thereof is intended to cover a non-exclusive inclusion. For example, a process, method, apparatus, article, or device that comprises a list of steps or elements is not limited to the list of steps or modules but may, in the alternative, include other steps or modules not listed or inherent to such process, method, apparatus, article, or device.
Those of ordinary skill in the art will appreciate that the elements and algorithm steps described in connection with the embodiments disclosed herein may be embodied in electronic hardware, in computer software, or in a combination of the two, and that the elements and steps of the examples have been generally described in terms of function in the foregoing description to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The methods and related devices provided in the embodiments of the present application are described with reference to the method flowcharts and/or structure diagrams provided in the embodiments of the present application, and each flowchart and/or block of the method flowcharts and/or structure diagrams may be implemented by computer program instructions, and combinations of flowcharts and/or blocks in the flowchart and/or block diagrams. 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 apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks. These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or structural diagram block or blocks. These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or structures.
The foregoing disclosure is only illustrative of the preferred embodiments of the present application and is not intended to limit the scope of the claims herein, as the equivalent of the claims herein shall be construed to fall within the scope of the claims herein.

Claims (14)

1. A method of blockchain consensus, the method comprising:
in a first-stage consensus period, if a transaction block is not acquired at the end of the first-stage consensus period, generating a first-stage local empty block as a local consensus result, and if the transaction block is acquired in the first-stage consensus period, verifying the transaction block, and generating a local consensus result according to the verification result; the first phase consensus period is used for representing the maximum duration of the first phase in the consensus process;
broadcasting a local consensus result to at least two consensus nodes, and acquiring a first-stage consensus result sent by the at least two consensus nodes and aiming at a transaction block;
determining the sum of the local consensus result for the transaction block and the number of the first-stage consensus results as a first-stage voting result number;
if the number of the voting results in the first stage is smaller than a first number threshold, generating a local empty block in the second stage; the local empty block in the second stage is a block with transaction data empty;
Broadcasting the second-stage local empty block to the at least two consensus nodes in a second-stage consensus period, and acquiring a second-stage consensus result sent by the at least two consensus nodes; the first-stage consensus period and the second-stage consensus period both belong to the consensus period for the transaction block, and the first-stage consensus period is earlier than the second-stage consensus period; the second-stage consensus period is used for representing the maximum duration of the second stage in the consensus process;
and determining the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result.
2. The method of claim 1, wherein the method further comprises:
if the number of the first-stage voting results is greater than or equal to the first number threshold, counting the number of first-stage voting empty blocks in the first-stage consensus result; the first-stage voting empty block is generated by a consensus node which detects that the transaction block does not meet the consensus condition in the at least two consensus nodes;
determining the number of first empty blocks according to the local consensus result and the number of first-stage voting empty blocks;
And if the number of the first empty blocks is larger than a second number threshold, generating the second stage local empty blocks.
3. The method of claim 2, wherein the determining a first number of empty blocks based on the local consensus result and the first stage number of voting empty blocks comprises:
if the local consensus result is a block voting success result aiming at the transaction block, determining the number of the first-stage voting empty blocks as the first empty block number;
and if the local consensus result is a first stage local empty block, taking the sum of the first stage local empty block and the number of first stage voting empty blocks as the first empty block number.
4. The method of claim 3, wherein the generating a local consensus result from the validation result comprises:
if the transaction block passes the verification, generating a block voting success result aiming at the transaction block, and taking the block voting success result aiming at the transaction block as the local consensus result;
and if the transaction block verification is not passed, generating the first-stage local empty block, and taking the first-stage local empty block as the local consensus result.
5. The method of claim 1, wherein the method further comprises:
if the number of the first-stage voting results is greater than or equal to the first number threshold, counting the number of first-stage voting success results in the first-stage consensus results; the successful voting result in the first stage is generated by a consensus node which detects that the transaction block meets the consensus condition in the at least two consensus nodes;
determining a first voting success number according to the local consensus result and the number of the first-stage voting success results;
if the first voting success number is greater than or equal to the first number threshold, a second-stage local consensus success result is generated, the second-stage local consensus success result is broadcast to the at least two consensus nodes, and a second-stage consensus result sent by the at least two consensus nodes is obtained;
and determining the uplink result of the transaction block according to the local consensus success result of the second stage and the second stage consensus result.
6. The method of claim 5, wherein the determining a first number of successful votes based on the local consensus result and the number of successful votes for the first stage comprises:
If the local consensus result is a block voting success result aiming at the transaction block, taking the sum of the local consensus result and the number of the first-stage voting success results as the first voting success number;
and if the local consensus result is a first stage local empty block, determining the number of the first stage voting success results as the first voting success number.
7. The method of claim 1, wherein said determining the uplink outcome of the transaction block based on the second stage local null block and the second stage consensus result comprises:
taking the number of second-stage consensus success results in the second-stage consensus results as a second voting success number;
if the second voting success number is greater than or equal to the first number threshold, uploading the transaction block to a block chain, and determining that the uplink result of the transaction block is an uplink success result;
and if the second voting success number is smaller than the first number threshold, deleting the transaction block, and determining that the uplink result of the transaction block is an uplink failure result.
8. The method of claim 1, wherein said determining the uplink outcome of the transaction block based on the second stage local null block and the second stage consensus result comprises:
Counting the number of second-stage consensus empty blocks in the second-stage consensus result;
taking the sum of the number of the second-stage local empty blocks and the second-stage consensus empty blocks as a second empty block number;
and if the number of the second empty blocks is larger than a second number threshold, deleting the transaction block, and determining that the uplink result of the transaction block is a uplink failure result.
9. The method of claim 1, wherein said determining the uplink outcome of the transaction block based on the second stage local null block and the second stage consensus result comprises:
determining the number of voting results of the second stage according to the local empty block of the second stage and the consensus result of the second stage;
and if the number of the voting results in the second stage is smaller than the first number threshold, deleting the transaction block, and determining that the uplink result of the transaction block is a uplink failure result.
10. The method of claim 1, wherein the method further comprises:
if the uplink result of the transaction block is a uplink failure result, acquiring a block generation node of the transaction block;
adding the block generating node to a permission limiting node set; the authority limit node set comprises consensus nodes without generating block authorities;
And acquiring the storage time length of the block generation node in the authority limit set, deleting the block generation node in the authority limit set if the storage time length is longer than the authority limit time, and recovering the block generation authority of the block generation node.
11. A blockchain consensus device, the device comprising:
the second consensus interaction module is used for generating a first-stage local empty block as a local consensus result in a first-stage consensus period if the transaction block is not acquired at the end of the first-stage consensus period;
the block verification module is used for verifying the transaction block if the transaction block is obtained in the first-stage consensus period;
the first result generation module is used for generating a local consensus result according to the verification result; the first phase consensus period is used for representing the maximum duration of the first phase in the consensus process;
the second consensus interaction module or the first result generation module is further configured to broadcast a local consensus result to at least two consensus nodes;
the consensus acquisition module is used for acquiring a first-stage consensus result aiming at the transaction block, which is sent by the at least two consensus nodes;
The voting number determining module is used for determining the sum of the local consensus result for the transaction block and the number of the first-stage consensus result as the number of the first-stage voting results;
the first empty block generation module is used for generating a second-stage local empty block if the number of the voting results in the first stage is smaller than a first number threshold value; the local empty block in the second stage is a block with transaction data empty;
the first consensus interaction module is used for broadcasting the second-stage local empty block to the at least two consensus nodes in a second-stage consensus period, and acquiring a second-stage consensus result sent by the at least two consensus nodes; the first-stage consensus period and the second-stage consensus period both belong to the consensus period for the transaction block, and the first-stage consensus period is earlier than the second-stage consensus period; the second-stage consensus period is used for representing the maximum duration of the second stage in the consensus process;
and the uplink result determining module is used for determining the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result.
12. The apparatus of claim 11, wherein the apparatus further comprises:
The empty block statistics module is used for counting the number of the first-stage voting empty blocks in the first-stage consensus result if the number of the first-stage voting results is greater than or equal to the first number threshold; the first-stage voting empty block is generated by a consensus node which detects that the transaction block does not meet the consensus condition in the at least two consensus nodes;
the empty block statistics module is further configured to determine a first number of empty blocks according to the local consensus result and the first number of empty blocks in the first stage;
and the second empty block generating module is used for generating the second-stage local empty block if the number of the first empty blocks is larger than a second number threshold value.
13. A computer device, comprising a processor, a memory, and an input-output interface;
the processor is respectively connected with the memory and the input/output interface, wherein the input/output interface is used for data interaction of each node in the blockchain, the memory is used for storing program codes, and the processor is used for calling the program codes to execute the method as claimed in any one of claims 1-10.
14. A computer readable storage medium, characterized in that the computer readable storage medium stores a computer program comprising program instructions which, when executed by a processor, perform the method of any of claims 1-10.
CN202010295981.2A 2020-04-15 2020-04-15 Block chain consensus method, apparatus, computer and readable storage medium Active CN111507840B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010295981.2A CN111507840B (en) 2020-04-15 2020-04-15 Block chain consensus method, apparatus, computer and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010295981.2A CN111507840B (en) 2020-04-15 2020-04-15 Block chain consensus method, apparatus, computer and readable storage medium

Publications (2)

Publication Number Publication Date
CN111507840A CN111507840A (en) 2020-08-07
CN111507840B true CN111507840B (en) 2024-03-26

Family

ID=71876134

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010295981.2A Active CN111507840B (en) 2020-04-15 2020-04-15 Block chain consensus method, apparatus, computer and readable storage medium

Country Status (1)

Country Link
CN (1) CN111507840B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112232954A (en) * 2020-10-15 2021-01-15 杭州溪塔科技有限公司 Dynamic adjustment method and device for proposal timeout threshold value and electronic equipment

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108648078A (en) * 2018-05-02 2018-10-12 杭州秘猿科技有限公司 A kind of transaction preprocess method, device and electronic equipment
WO2018223215A1 (en) * 2017-06-07 2018-12-13 Zeu Crypto Networks Inc. Scalable trading platform using central bank issued digital currency
CN109447810A (en) * 2018-11-29 2019-03-08 杭州秘猿科技有限公司 Parallel block chain common recognition method, system, electronic equipment and computer readable storage medium
CA3053208A1 (en) * 2018-12-13 2019-04-18 Alibaba Group Holding Limited Performing a change of primary node in a distributed system
CN110445778A (en) * 2019-08-01 2019-11-12 中盾云链(广州)信息科技有限公司 A kind of common recognition algorithm applied to alliance's chain
CN110493148A (en) * 2019-08-12 2019-11-22 深圳前海微众银行股份有限公司 A kind of block processes, block common recognition and block synchronous method and device
US10504179B1 (en) * 2015-12-08 2019-12-10 Fmr Llc Social aggregated fractional equity transaction partitioned acquisition apparatuses, methods and systems
CN110572429A (en) * 2019-07-30 2019-12-13 中钞信用卡产业发展有限公司杭州区块链技术研究院 block chain-based consensus method, device, equipment and storage medium
WO2020011283A2 (en) * 2019-09-05 2020-01-16 Alibaba Group Holding Limited System and method for deleting node in blockchain network
CN110765211A (en) * 2019-11-06 2020-02-07 腾讯科技(深圳)有限公司 Engineering bid inviting management method, device, terminal and storage medium based on block chain
CN110995701A (en) * 2019-12-02 2020-04-10 远光软件股份有限公司 Block chain consensus method, system, electronic equipment and storage medium

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10504179B1 (en) * 2015-12-08 2019-12-10 Fmr Llc Social aggregated fractional equity transaction partitioned acquisition apparatuses, methods and systems
WO2018223215A1 (en) * 2017-06-07 2018-12-13 Zeu Crypto Networks Inc. Scalable trading platform using central bank issued digital currency
CN108648078A (en) * 2018-05-02 2018-10-12 杭州秘猿科技有限公司 A kind of transaction preprocess method, device and electronic equipment
CN109447810A (en) * 2018-11-29 2019-03-08 杭州秘猿科技有限公司 Parallel block chain common recognition method, system, electronic equipment and computer readable storage medium
CA3053208A1 (en) * 2018-12-13 2019-04-18 Alibaba Group Holding Limited Performing a change of primary node in a distributed system
CN110572429A (en) * 2019-07-30 2019-12-13 中钞信用卡产业发展有限公司杭州区块链技术研究院 block chain-based consensus method, device, equipment and storage medium
CN110445778A (en) * 2019-08-01 2019-11-12 中盾云链(广州)信息科技有限公司 A kind of common recognition algorithm applied to alliance's chain
CN110493148A (en) * 2019-08-12 2019-11-22 深圳前海微众银行股份有限公司 A kind of block processes, block common recognition and block synchronous method and device
WO2020011283A2 (en) * 2019-09-05 2020-01-16 Alibaba Group Holding Limited System and method for deleting node in blockchain network
CN110765211A (en) * 2019-11-06 2020-02-07 腾讯科技(深圳)有限公司 Engineering bid inviting management method, device, terminal and storage medium based on block chain
CN110995701A (en) * 2019-12-02 2020-04-10 远光软件股份有限公司 Block chain consensus method, system, electronic equipment and storage medium

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
基于共识决策的低碳供应商选择方法研究;程发新;程栋;赵艳萍;罗建强;;运筹与管理;20121231;第21卷(第06期);全文 *
基于学习元平台的师生共读活动之社会网络分析和内容分析;钟伟;吴娟;陈露;;现代远距离教育(第01期);全文 *
复杂网络模糊重叠社区检测研究进展;肖婧;张永建;许小可;;复杂系统与复杂性科学;第14卷(第03期);全文 *

Also Published As

Publication number Publication date
CN111507840A (en) 2020-08-07

Similar Documents

Publication Publication Date Title
CN111600720B (en) Data processing method, device and equipment based on block chain and readable storage medium
CN112446785B (en) Cross-chain transaction method, system, device, equipment and storage medium
CN111461885B (en) Consensus network management method, device, computer and readable storage medium
CN111209339B (en) Block synchronization method, device, computer and storage medium
CN112134762B (en) Testing method, device, terminal and storage medium for block chain network structure
CN111614761B (en) Block chain message transmission method, device, computer and readable storage medium
CN111556115B (en) Block chain-based data processing method, device, equipment and storage medium
CN110570196A (en) Transaction data processing method and device, terminal equipment and storage medium
CN111343212B (en) Message processing method, device, equipment and storage medium
CN113326165B (en) Data processing method and device based on block chain and computer readable storage medium
CN110659967B (en) House management method and device based on block chain
CN111339141B (en) Data transmission method, block chain node equipment and medium
CN113852470B (en) Proposal broadcasting method, device, equipment and storage medium
CN110599180A (en) Block chain-based vaccine circulation management method and device
US20250200564A1 (en) Blockchain-based data processing method and apparatus, device, and readable storage medium
CN112069529B (en) Block chain-based volume management method and device, computer and storage medium
CN113901519A (en) Data processing method, device, equipment and medium based on block chain
CN111507840B (en) Block chain consensus method, apparatus, computer and readable storage medium
CN111953540B (en) Message generation method and device, electronic equipment and storage medium
CN112200680A (en) Block link point management method, device, computer and readable storage medium
HK40027390A (en) Block-chain consensus method adn device, computer and readable storage medium
CN114371948A (en) Service message notification method, device, computer equipment and storage medium
CN113435914A (en) Asset authentication method, storage medium and system based on block chain data structure
CN113221151A (en) Data processing method and device based on block chain and storage medium
HK40027388A (en) Data processing method and device based on block-chain, apparatus and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40027390

Country of ref document: HK

SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant