WO2025214030A1 - 区块提案方法、装置、电子设备和可读介质 - Google Patents

区块提案方法、装置、电子设备和可读介质

Info

Publication number
WO2025214030A1
WO2025214030A1 PCT/CN2025/081601 CN2025081601W WO2025214030A1 WO 2025214030 A1 WO2025214030 A1 WO 2025214030A1 CN 2025081601 W CN2025081601 W CN 2025081601W WO 2025214030 A1 WO2025214030 A1 WO 2025214030A1
Authority
WO
WIPO (PCT)
Prior art keywords
proposal
transactions
block
blockchain
consensus
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.)
Pending
Application number
PCT/CN2025/081601
Other languages
English (en)
French (fr)
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.)
Tencent Technology (Shenzhen) Co Ltd
Original Assignee
Tencent Technology (Shenzhen) 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 Tencent Technology (Shenzhen) Co Ltd filed Critical Tencent Technology (Shenzhen) Co Ltd
Publication of WO2025214030A1 publication Critical patent/WO2025214030A1/zh
Anticipated expiration legal-status Critical
Pending legal-status Critical Current

Links

Classifications

    • G—PHYSICS
    • G06—COMPUTING OR CALCULATING; COUNTING
    • G06F—ELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23—Updating
    • G06F16/2379—Updates performed during online database operations; commit processing
    • G—PHYSICS
    • G06—COMPUTING OR CALCULATING; COUNTING
    • G06F—ELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23—Updating
    • G—PHYSICS
    • G06—COMPUTING OR CALCULATING; COUNTING
    • G06F—ELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • G—PHYSICS
    • G06—COMPUTING OR CALCULATING; COUNTING
    • G06Q—INFORMATION 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/00—Payment architectures, schemes or protocols
    • G06Q20/38—Payment protocols; Details thereof
    • G—PHYSICS
    • G06—COMPUTING OR CALCULATING; COUNTING
    • G06Q—INFORMATION 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/00—Payment architectures, schemes or protocols
    • G06Q20/38—Payment protocols; Details thereof
    • G06Q20/389—Keeping log of transactions for guaranteeing non-repudiation of a transaction

Definitions

  • the present application relates to the field of computer technology, in particular to the field of blockchain technology, and more particularly to a block proposal method, device, electronic device, and readable medium.
  • blockchain nodes package multiple blockchain transactions into a proposal to reach consensus among blockchain nodes. Only after consensus is reached will a block be generated in the blockchain.
  • blockchain nodes package blockchains for proposals according to preset upper limits on the number of block transactions and the maximum time it takes for block execution.
  • the proposal process will package as many transactions as possible according to the block execution time limit, making the execution time of the proposal block close to the execution time limit. This may cause other nodes to exceed the block execution time limit when verifying the proposal and oppose the consensus, thereby causing the proposal to fail and affecting the operating efficiency of the blockchain.
  • the present application provides a block proposal method, device, electronic device and readable medium.
  • a block proposal method is provided, which is executed by a blockchain node in a blockchain, comprising:
  • each voting result including a number of suggested transactions, where the number of suggested transactions is determined based on the number of first proposal transactions in the first block proposal and an execution time of the first block proposal by the blockchain node that generated the voting result;
  • the blockchain transactions in the local transaction pool are packaged to generate a second block proposal for voting by multiple blockchain nodes in the second consensus round of the blockchain;
  • the second block proposal is broadcasted in the blockchain.
  • a block proposal device including:
  • an acquisition module configured to acquire a plurality of voting results generated by a plurality of blockchain nodes in a first consensus round in a blockchain for a first block proposal, each voting result comprising a number of suggested transactions, the number of suggested transactions being determined based on the number of first proposal transactions in the first block proposal and an execution time of the first block proposal by the blockchain node generating the voting result;
  • a generating module configured to generate a transaction quantity limit for a second consensus round based on the number of recommended transactions included in each of the plurality of voting results, where the second consensus round is a subsequent consensus round of the first consensus round;
  • a packaging module configured to package the blockchain transactions in the local transaction pool according to the transaction quantity limit and generate a second block proposal for voting by multiple blockchain nodes in a second consensus round in the blockchain;
  • a broadcasting module is configured to broadcast the second block proposal in the blockchain.
  • an electronic device comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the block proposal method in the above technical solution by executing the executable instructions.
  • a computer-readable storage medium on which a computer program is stored.
  • the computer program is executed by a processor, the block proposal method in the above technical solution is implemented.
  • a computer program product or computer program comprising computer instructions stored in a computer-readable storage medium.
  • a processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the electronic device to perform the block proposal method provided in the various optional implementations described above.
  • FIG1 is a schematic diagram of an exemplary system architecture of the technical solution of the present application in an application scenario.
  • FIG2 is a schematic diagram of the overall situation of the block proposal in the embodiment of the present application.
  • FIG3 is a schematic diagram of a blockchain network in an embodiment of the present application.
  • FIG4 is a schematic diagram of blocks in a blockchain network according to an embodiment of the present application.
  • FIG5 shows a flowchart of a block proposal method according to an embodiment of the present application.
  • FIG6 shows a flowchart of a block proposal method according to an embodiment of the present application.
  • FIG7 is a logical diagram of generating a transaction limit for the second consensus round in an embodiment of the present application.
  • FIG8 is another logical diagram of generating a transaction limit for the second consensus round in an embodiment of the present application.
  • FIG9 is another logical diagram of generating a transaction limit for the second consensus round in an embodiment of the present application.
  • FIG10 shows a flowchart of a block proposal method according to an embodiment of the present application.
  • FIG11 is a schematic diagram of the node voting results in an embodiment of the present application.
  • FIG12 is a schematic diagram of the specific structure of the node voting results in an embodiment of the present application.
  • FIG13 is a schematic flowchart of the overall process of block proposal processing in an embodiment of the present application.
  • FIG14 schematically shows a block diagram of the composition of the block proposal device in an embodiment of the present application.
  • FIG15 shows a schematic structural diagram of a computer system suitable for implementing an electronic device according to an embodiment of the present application.
  • module refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof.
  • a processor or multiple processors or memories
  • each module or unit can be part of an overall module or unit that includes the function of the module or unit.
  • the block header is a part of each block in the blockchain. It contains information such as the input information characteristic value, version number, timestamp, difficulty value, and the block header characteristic value of the parent block. It is used to ensure that the block data stored in each block in the blockchain is associated with the block data stored in the parent block, ensuring the security of the input information in the block.
  • a blockchain transaction is an operational unit of interaction between blockchain nodes in a blockchain system, performing a series of interactive activities such as data transmission, processing, and verification.
  • a blockchain node packages multiple such transactions into a proposal, which is then negotiated among the nodes. Once consensus is reached, a block containing these transactions is generated within the blockchain. This operation is subject to limits such as the number of transactions and the duration of execution.
  • blockchain nodes will propose a number of transactions to include in the next round of consensus proposals based on the execution status of the proposed transactions. This allows for dynamic adjustment of the number of transactions in each block, thereby improving the efficiency of the blockchain.
  • the current industry-wide solution is to set an upper limit for these two parameters.
  • the upper limit is typically set based on the number of transactions per second and business needs, while the duration is often fixed, such as 10 seconds.
  • Transaction volume refers to the number of transactions (or transactions) occurring per unit of time in a blockchain system. It is often used to measure a blockchain system's processing capacity and business volume.
  • the upper limit is typically set based on the number of transactions per second and business needs.
  • the master node of the proposal will definitely try to pack more transactions into the proposal, so the execution time will be longer, but it will definitely be less than 10 seconds (for example, 9.8 seconds).
  • the slave node is different. It will also execute all transactions in this block. Once the execution time exceeds 10 seconds due to factors such as server performance and resource usage, the slave node will consider the master node's proposal problematic and vote against it. This may lead to the failure to reach consensus in this round and the need to re-consensus, affecting the overall performance of the blockchain.
  • the technical solution of the embodiment of the present application proposes a block proposal solution.
  • the system architecture applied to the block proposal solution according to the embodiment of the present application may include a blockchain network composed of four blockchain nodes.
  • Electronic devices that implement blockchain nodes may include smart phones, tablet computers, laptops, intelligent voice interaction devices, smart home appliances, vehicle terminals, aircraft, etc.
  • the electronic devices that implement blockchain nodes may also be servers that provide various services. They may be independent physical servers, or server clusters or distributed systems composed of multiple physical servers.
  • cloud servers may also be cloud servers that provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.
  • cloud servers that provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.
  • communication media for communication links between blockchain nodes, such as wired communication links or wireless communication links.
  • the system architecture in the embodiments of the present application can include any number of terminal devices and servers.
  • the electronic device implementing a blockchain node can be a server group consisting of multiple server devices.
  • the technical solutions provided in the embodiments of the present application can be applied to any blockchain node, or can be implemented by multiple blockchain nodes, and this application does not impose any specific restrictions on this.
  • a blockchain node acts as a master node 110 in the blockchain to make proposals.
  • the master node can be any consensus node in the blockchain, and consensus nodes in the blockchain typically rotate as the master node according to predetermined rules to make proposals. Consensus nodes other than the master node become slave nodes. Slave nodes vote based on the master node's proposals to reach consensus. Once consensus is reached, the master node confirms that each slave node is notified to upload the new block to the blockchain.
  • the master node 110 in the blockchain sends a block proposal to the slave nodes 120.
  • the slave nodes 120 When the slave nodes send their votes on the block proposal to the master node 110, the slave nodes 120 also provide a recommended number of transactions to be included in the next round of proposals. All slave nodes 120 vote and provide a recommended number. The master node 110 then determines the number of transactions to be included in the next round of proposals based on the recommendations provided by the slave nodes 120. The transactions are then included according to the recommended number in the next round of proposals.
  • FIG 2 is a schematic diagram of the overall situation of a block proposal in an embodiment of the present application.
  • the master node will package a set of transactions (10,000) and execute them, forming a block proposal. Assume that the master node takes 9.8 seconds to execute all transactions in the block proposal.
  • the block proposal is broadcast to the slave nodes in the blockchain. Nodes 2, 3, and 4 will verify the received proposal.
  • Each node will execute all transactions in the received block proposal and determine the content of the vote based on the execution results. For example, it will vote for or against the block based on the success or failure of all transactions.
  • the node will also calculate the execution time of all transactions in the execution proposal and the execution timeout.
  • the node's vote will be against.
  • the node also generates a recommended number of transactions based on the execution time and the number of transactions included in the proposal. For example, due to the execution timeout, the slave node may recommend setting the number of transactions to 5,000.
  • the slave node will include its recommended number of transactions in the voting information for the proposal.
  • the votes of the slave nodes are broadcast to other nodes. All nodes in the blockchain collect the votes of other nodes regarding the proposal and, based on this information, decide whether to approve the block's inclusion in the second round of voting.
  • each node will also vote against committing the block. Each node will then collect the votes of other nodes in the second round of voting before making a final decision on whether to commit the block. Furthermore, each node will determine a new transaction limit for proposals based on the number of transactions suggested by each slave node. In the next round of consensus, the master node will package transactions according to the proposed transaction limit it has determined. For example, if a majority of nodes recommend 5,000 transactions, the master node will package all 5,000 transactions into a proposal for the next round of proposals.
  • Blockchain is a novel application model for computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms.
  • a blockchain is a decentralized database, a series of data blocks (i.e., blocks) generated using cryptographic methods. Each block contains information about a batch of network transactions, used to verify the validity of the information (forgery prevention) and generate the next block.
  • a blockchain is maintained by the nodes in the blockchain network.
  • the blockchain network shown in Figure 3 may include multiple nodes 301, which may be the various clients that form the blockchain network. Each node 301 can receive input information during normal operation and maintain shared data within the blockchain network based on the received input information.
  • information connections can be established between each node in the blockchain network, allowing nodes to transmit information through these connections. For example, when any node in the blockchain network receives input information, other nodes in the blockchain network obtain the input information according to the consensus algorithm and store it as shared data, ensuring that the data stored by all nodes in the blockchain network is consistent.
  • a consensus algorithm is an algorithm used by multiple nodes in a blockchain network to reach consensus on block proposals. Through this algorithm, nodes can obtain input information and store it as shared data, so that the data stored on all nodes in the blockchain network is consistent.
  • Each node in a blockchain network has a corresponding node identifier, and each node in the blockchain network can store the node identifiers of other nodes so that it can subsequently broadcast generated blocks to other nodes in the blockchain network based on the node identifiers of other nodes.
  • Each node can maintain a node identifier list, storing the node name and node identifier in the node identifier list.
  • the node identifier can be an IP (Internet Protocol) address or any other information that can be used to identify the node.
  • Node identification list A list maintained by each node in the blockchain network, used to store the corresponding node name and node identification.
  • the node identification can be an IP (Internet Protocol, a protocol for interconnecting networks) address or any other information that can be used to identify the node, so that the node can subsequently broadcast the generated blocks to other nodes in the blockchain network based on the node identification of other nodes.
  • IP Internet Protocol, a protocol for interconnecting networks
  • Each node in a blockchain network stores an identical blockchain.
  • a blockchain consists of multiple blocks.
  • the genesis block includes a block header and a block body.
  • the block header stores input information features, a version number, a timestamp, and a difficulty value, while the block body stores the input information.
  • the next block of the genesis block uses the genesis block as its parent block.
  • the next block also includes a block header and a block body.
  • the block header stores the input information features of the current block, the block header features, version number, timestamp, and difficulty value of the parent block, and so on. This ensures that the block data stored in each block in the blockchain is linked to the block data stored in the parent block, ensuring the security of the input information in the block.
  • the Genesis block is the first block in the blockchain, which contains a block header and a block body.
  • the block header stores the input information feature value, version number, timestamp, difficulty value, etc.
  • the block body stores the input information and is the basis for subsequent blocks. Subsequent blocks are generated in sequence with this as the parent block.
  • Parent block In a blockchain, each block has a predecessor, which is the parent block of the current block. Each block's header stores the characteristic value of the parent block's header. This ensures that the block data stored in each block in the blockchain is linked to the block data stored in the parent block, ensuring the security of the information entered into the block.
  • the blockchain data obtained by the master node 110 and the slave node 120 may be in a block structure as shown in FIG4 . It is understood that although three blocks are shown, the master node 110 and the slave node 120 may obtain more or fewer blocks at a time, or may obtain all blocks in the blockchain at once.
  • the relevant information of the number of recommended transactions can be stored in the block body of the blockchain structure shown in Figure 4 in the form of a blockchain transaction, and consensus can be reached between nodes along with the block and uploaded to the blockchain.
  • FIG5 shows a flowchart of a block proposal method according to one embodiment of the present application.
  • the block proposal method can be performed by a device with computing processing capabilities, such as a computing device of a blockchain node.
  • the block proposal method includes at least steps S510 to S540, which are described in detail as follows:
  • Step S510 Obtain multiple voting results generated by multiple blockchain nodes for the first block proposal in the first consensus round in the blockchain, where each voting result includes the number of recommended transactions, and the number of recommended transactions is determined based on the number of first proposal transactions in the first block proposal and the execution time of the first block proposal by the blockchain node that generates the voting result.
  • the first consensus round is the round in which voting and consensus are reached on the first block proposal during the blockchain consensus process.
  • the first consensus round is the current consensus round.
  • the second consensus round is the next consensus round after the first consensus round.
  • the master node will package blockchain transactions and propose them according to the transaction limit of the second consensus round determined in the previous round.
  • the first block proposal is a block proposal generated by the master node of the current consensus round (the first consensus round) by packaging blockchain transactions, and is used for consensus among blockchain nodes.
  • a transaction is an operational unit for a series of interactive activities between blockchain nodes, such as data transmission, processing, and verification.
  • Blockchain nodes will package multiple such transactions into a proposal and reach consensus among blockchain nodes. Once consensus is reached, a block containing these transaction information is generated in the blockchain.
  • Suggested transaction quantity refers to a quantity value determined based on the number of first proposal transactions in the first block proposal and the execution time of the first block proposal by the blockchain node that generates the voting result. This quantity value represents the recommendation made by the voting node on the number of transactions to be included in the next round of consensus proposal based on its execution of the first block proposal.
  • First proposed transaction quantity refers to the number of transactions used when the first block proposal is packaged.
  • the current blockchain node i.e., the blockchain node currently executing the block proposal method
  • the first block proposal is the block generated by the master node of the current consensus round. It is understood that the transaction limit adopted when packaging the first block proposal can also be determined according to the solution of this application.
  • the voting result is determined by each node in the blockchain based on the verification and execution results of the first block proposal. It includes the node's vote on the first block proposal, typically a vote of approval or disapproval, and the recommended number of transactions.
  • the recommended number of transactions is determined based on the number of first proposal transactions in the first block proposal and the execution time of the first block proposal by the blockchain node that generated the voting result. It represents the voting node's recommendation on the number of transactions to be included in the next consensus round proposal based on its execution of the first block proposal. It is understandable that if the voting node finds that the execution of the first block proposal has timed out, the number of recommended transactions determined will be less than the number of first proposal transactions. If the voting node finds that the execution time is far from the preset maximum time after executing the first block proposal, it will propose a larger number of recommended transactions than the number of first proposal transactions.
  • the multiple voting results generated by multiple blockchain nodes for the first block proposal in the first consensus round obtained by the local node do not necessarily come from all nodes in the blockchain, but only as long as the number of votes obtained meets the conditions for determining the consensus result in the consensus strategy of the blockchain. That is, if the consensus condition requires that half of the nodes agree to reach a consensus, the local node only needs to obtain half of the votes in favor or against to determine the consensus result and execute the solution of this application. In this application, multiple can be at least two.
  • Step S520 Generate a transaction limit for a second consensus round based on the number of recommended transactions included in each of the multiple voting results.
  • the second consensus round is the next consensus round after the first consensus round.
  • the transaction quantity limit refers to the limit on the number of transactions used by the master node when making a proposal in a consensus round. This value is generated by the number of proposed transactions in the voting results of multiple blockchain nodes for the previous block proposal in the previous consensus round.
  • the local node generates a transaction limit for the second consensus round based on the number of proposed transactions in the multiple voting results generated by multiple blockchain nodes for the first block proposal during the first consensus round.
  • the second consensus round is the next consensus round after the first.
  • the transaction limit for the second consensus round will be used as the transaction limit for proposals made by the master node in the next consensus round.
  • a portion of the proposed transaction numbers can be selected from the multiple voting results generated by multiple blockchain nodes for the first block proposal during the first consensus round according to a preset generation strategy.
  • the execution time is shorter than a preset time, a number of proposed transactions greater than the number of transactions in the first proposal will be selected, while if the execution time exceeds a preset time, a number of proposed transactions less than the number of transactions in the first proposal will be selected.
  • the transaction limit for the second consensus round is then determined based on the selected number of proposed transactions.
  • the limit can be the mean, maximum, median, or a combination of these.
  • Step S530 Pack the blockchain transactions in the local transaction pool according to the transaction quantity limit, and generate a second block proposal for voting by multiple blockchain nodes in the second consensus round in the blockchain.
  • the local transaction pool is a collection of blockchain transactions stored locally on blockchain nodes.
  • the master node will obtain transactions from the pool and package them to generate block proposals.
  • the local node becomes the master node in the next consensus round. After becoming the master node, the local node will determine whether to package transactions for the first block proposal and upload them to the blockchain based on the voting results of the previous round. Regardless of whether the first block proposal reaches consensus, in the next consensus round, when the master node needs to make a proposal, it will use the transaction limit for the second consensus round determined in the previous consensus round as the transaction limit for the proposal. Specifically, the local node will package the blockchain transactions within the transaction limit in the local transaction pool, generate a second block proposal for voting by multiple blockchain nodes in the second consensus round of the blockchain, and broadcast the second block proposal to the blockchain.
  • the specific transactions included in the second block proposal may be the same or different from those in the first block proposal.
  • the local node when packaging the second block proposal, the local node will execute the transactions to be packaged and calculate the execution time. The local node will ensure that the number of transactions in the second block proposal is less than or equal to the transaction limit and that the total execution time of all transactions in the second block proposal does not exceed the preset execution time threshold in the blockchain.
  • Total execution time The total time a blockchain node spends executing all blockchain transactions in a block proposal. Based on this execution time and the number of completed transactions, the node generates a suggested number of transactions.
  • the suggested quantity of transactions is synonymous with the suggested quantity of transactions, a value generated by the node based on the total execution time and number of completed transactions in the block proposal. This value represents the node's recommendation for the number of transactions to be included in the next consensus proposal, based on its execution of the block proposal. This value is included in the voting results.
  • Step S540 broadcast the second block proposal in the blockchain.
  • the second block proposal is a block proposal generated by the master node in the next consensus round (the second consensus round) by packaging the blockchain transactions in the local transaction pool according to the transaction limit of the second consensus round. It is used to instruct multiple blockchain nodes in the second consensus round in the blockchain to vote.
  • the local node acting as the master node for the current consensus round (the previous consensus round after the completion of the first block proposal), broadcasts the second block proposal to the blockchain.
  • the slave nodes in the blockchain then proceed to the consensus process based on the second block proposal and, upon reaching consensus, generate the block submitted by the second block proposal.
  • each slave node will also recommend a transaction limit based on the number of transactions and execution time of the second block proposal, thereby further adjusting the number of transactions to be packaged in the block proposal for the next consensus round. Therefore, the transaction limit in the block proposal is dynamically adjusted based on the number of transactions recommended by each slave node during the consensus process. This can promptly address issues such as excessive transactions leading to timeouts or insufficient transactions leading to wasted resources during operation, without the need for manual intervention or configuration, resulting in more efficient blockchain operations.
  • the blockchain node after obtaining multiple voting results generated by multiple blockchain nodes for the first block proposal in the first consensus round for the first block proposal, the blockchain node will generate a transaction limit for the second consensus round based on the number of recommended transactions in each voting result.
  • the second consensus round is the next consensus round after the first consensus round, and when becoming a proposal node, it will package blockchain transactions into a new block proposal according to the determined transaction limit for the second consensus round, and broadcast it in the blockchain to generate a new block in the blockchain.
  • the number of transactions packaged for the next proposal is adjusted according to the suggestions of each node, so that the transactions included in the block proposal can be automatically adjusted during the execution result and execution time of the proposal, avoiding too many transactions in the block proposal causing execution timeout when verifying the proposal, and then preventing the proposal from failing due to execution timeout, which is beneficial to improving the operation efficiency of the blockchain.
  • a block proposal method in one embodiment of the present application may include the following steps:
  • Step S610 Obtain multiple voting results generated by multiple blockchain nodes for the first block proposal in the first consensus round in the blockchain, where each voting result includes the number of recommended transactions, and the number of recommended transactions is determined based on the number of first proposal transactions in the first block proposal and the execution time of the first block proposal by the blockchain node that generates the voting result.
  • step S610 is consistent with those of step S510 shown in FIG5 , and are not described again.
  • Step S620 Determine a consensus result for the first block proposal based on multiple voting results generated by multiple blockchain nodes for the first block proposal in the first consensus round;
  • the proposal consensus result refers to the result on whether the first block proposal has reached consensus after judging the multiple voting results generated by multiple blockchain nodes in the first consensus round for the first block proposal based on the blockchain's consensus strategy. It is usually divided into proposal success and proposal failure.
  • Step S630 Based on the proposal consensus result, a voting result corresponding to the proposal consensus result is obtained from the multiple voting results generated by the multiple blockchain nodes in the first consensus round for the first block proposal as a candidate voting result;
  • Candidate voting result refers to the voting result corresponding to the proposal consensus result, obtained from the multiple voting results generated by multiple blockchain nodes for the first block proposal in the first consensus round based on the proposal consensus result, and is used to generate the transaction limit for the second consensus round.
  • Step S640 Generate a transaction limit for the second consensus round based on the number of recommended transactions in the candidate voting results.
  • the second consensus round is the next consensus round after the first consensus round.
  • the local node when generating the transaction limit for the second consensus round, the local node will, based on the proposal consensus result, obtain the voting result corresponding to the proposal consensus result from the multiple voting results generated by multiple blockchain nodes for the first block proposal during the first consensus round. Specifically, the local node will first determine the proposal consensus result for the first block proposal based on the multiple voting results generated by multiple blockchain nodes for the first block proposal during the first consensus round. This determination process is typically determined based on the blockchain's consensus policy.
  • Consensus network A network composed of multiple blockchain nodes in which nodes vote and reach consensus on block proposals. Different consensus networks have different consensus strategies. For example, in a 3f+1 consensus network, for each round of voting, each node only needs to collect 2f+1 votes to determine consensus success, or f+1 votes to determine consensus failure.
  • the local node After determining the consensus result for a proposal, the local node will retrieve the voting results corresponding to the consensus result from the multiple voting results generated by multiple blockchain nodes for the first block proposal during the first consensus round, as candidate voting results. Specifically, the multiple voting results generated by multiple blockchain nodes for the first block proposal during the first consensus round have varying degrees of influence and impact on the consensus result. The local node selects voting results based on the degree of influence, correlation, and impact of each voting result on the consensus result. Typically, the local node selects voting results that have a positive impact on the consensus result as candidate voting results. The impact of voting results is generally categorized as positive, negative, or no impact.
  • a positive impact indicates that the direction of the consensus result is consistent
  • a negative impact indicates that the direction of the consensus result is opposite
  • no impact indicates that the result has no correlation with the consensus result.
  • a negative vote has a positive impact
  • a positive vote has a negative impact
  • an abstention has no impact.
  • the local node will select a portion of the positive voting results and the negative voting results respectively as candidate voting results according to a preset ratio.
  • the local node will generate a transaction limit for the second consensus round based on the number of proposed transactions in the candidate voting results.
  • the second consensus round is the next consensus round of the first consensus round.
  • the second consensus round is the next consensus round of the first consensus round, so that the influence of the correct voting results in the determination factors of the transaction limit of the second consensus round can be higher, which is conducive to improving the accuracy of the transaction limit determined for the second consensus round.
  • Step S650 Pack the blockchain transactions in the local transaction pool according to the transaction quantity limit, and generate a second block proposal for voting by multiple blockchain nodes in the second consensus round in the blockchain.
  • step S650 implementation details of step S650 are consistent with those of step S530 shown in FIG5 , and are not described again.
  • Step S660 broadcast the second block proposal in the blockchain.
  • step S660 implementation details of step S660 are consistent with those of step S540 shown in FIG5 , and are not described again.
  • the blockchain node after obtaining multiple voting results generated by multiple blockchain nodes for the first block proposal in the first consensus round for the first block proposal, the blockchain node will generate a transaction limit for the second consensus round based on the number of recommended transactions in each voting result, and when becoming a proposal node, it will package blockchain transactions into a new block proposal according to the determined transaction limit for the second consensus round, and broadcast it in the blockchain to generate a new block in the blockchain.
  • the number of transactions packaged for the next proposal is adjusted according to the suggestions of each node, so that the transactions included in the block proposal can be automatically adjusted during the execution result and execution time of the proposal, avoiding too many transactions in the block proposal causing execution timeout when verifying the proposal, and then preventing the proposal from failing due to execution timeout, which is beneficial to improving the operation efficiency of the blockchain.
  • the node uses the voting results of the multiple voting results generated by the multiple blockchain nodes in the first consensus round for the first block proposal as the candidate voting results. If the proposal consensus result is that the proposal fails, then the node uses the voting results of the multiple voting results generated by the multiple blockchain nodes in the first consensus round for the first block proposal as the candidate voting results.
  • the local node will select the voting results whose voting content is consistent with the proposal consensus result as the candidate voting results, thereby avoiding the influence of the number of suggestions proposed by the nodes that have made incorrect judgments on the consensus node on the determined specified number, which is beneficial to reduce the probability that the process of determining the number of transactions is affected by malicious data and improve the security of the blockchain system.
  • the node uses the number of first proposal transactions as the transaction limit for the second consensus round. If the number of first proposal transactions is less than the number of proposed transactions in the candidate voting results, the node generates the transaction limit for the second consensus round based on the average of the number of first proposal transactions and the number of selected proposed transactions.
  • the consensus result is a successful proposal consensus
  • the number of first proposal transactions is greater than or equal to the number of recommended transactions in the candidate voting result, it means that the slave node recognizes the number packaged by the master node, and the number of first proposal transactions can be directly used as the transaction limit for the second consensus round.
  • Figure 7 is a logical diagram of generating the transaction limit for the second consensus round in an embodiment of the present application. As shown in Figure 7, the number of recommended transactions proposed by node 2 is consistent with the number packaged by the master node.
  • node 2 becomes the master node in the next round, the number packaged by the master node will be directly used as the packaged number in the next round of consensus. It should be noted that since node 4 voted against it, the number of recommended transactions it provided does not need to be considered. If node 4 becomes the master node in the next round, the number packaged by the master node (i.e., 10,000 transactions) will also be directly used as the packaged number in the next round of consensus. If the number of transactions in the first proposal is less than the number of transactions recommended in the candidate voting results, it means that the slave node does not approve of the number of transactions packaged by the master node.
  • the node can generate a transaction limit for the second consensus round based on the average of the number of transactions in the first proposal and the number of transactions selected.
  • Figure 8 is another logical diagram of generating a transaction limit for the second consensus round in an embodiment of the present application.
  • the number of transactions proposed by node 2 is 10,000, while the master node only packages 5,000. At this time, node 2 does not approve of the number of transactions packaged by the master node.
  • node 2 becomes the master node it will determine the transaction limit for the second consensus round based on the average of the two numbers, that is, 7,500.
  • Node 4 is similar.
  • the number of transactions proposed by it is 6,000, which is also higher than the number of transactions packaged by the master node.
  • the transaction limit for the second consensus round is determined based on the comparison result of the number of transactions proposed by the slave nodes and the number of transactions packaged by the master node.
  • the candidate voting results include multiple voting results generated by multiple blockchain nodes for the first block proposal in the first consensus round. If the number of transactions in the first proposal is less than the number of proposed transactions in the candidate voting results, then the transaction limit for the second consensus round is generated based on the average of the number of transactions in the first proposal and the selected number of proposed transactions. If the number of transactions in the first proposal is less than the number of proposed transactions in the candidate voting results, the node obtains the block transaction number threshold of the blockchain. If the number of proposed transactions for any voting result in the candidate voting results is greater than the block transaction number threshold, the voting result is deleted from the candidate voting results.
  • the node generates the transaction limit for the second consensus round based on the average of the number of transactions in the first proposal and the number of proposed transactions for each voting result in the candidate voting results.
  • the proposed transaction number will be discarded, thereby avoiding the failure of consensus caused by the proposal execution timeout due to an excessive number of transactions in the block proposal, which is beneficial to improving the stability of the solution.
  • the block transaction quantity threshold is a maximum limit configured on the blockchain, which is used to limit the number of transactions in a block proposal. If the number of proposed transactions determined by the slave node is higher than the threshold, the proposed transaction quantity will be discarded.
  • the node in the process of generating the transaction limit for the second consensus round based on the number of proposed transactions in the candidate voting results, if the proposal consensus result is that the proposal fails, the node obtains the number of proposed transactions in the candidate voting results, and then determines the transaction limit for the second consensus round based on the sum of the number of proposed transactions in the candidate voting results and the number of candidate voting results. In this embodiment, if the proposal consensus fails, only the number of proposed transactions in the voting results of the negative votes will be selected to determine the transaction limit for the second consensus round.
  • Figure 9 is another logical diagram of generating the transaction limit for the second consensus round in an embodiment of the present application.
  • the local node will only select the voting results of node 3 and node 4 containing the opposing votes as the candidate voting results, and the transaction limit for the second consensus round determined is also the average of the two recommended numbers.
  • the transaction limit for the second consensus round can be determined in other ways, such as the maximum or minimum value, or by clustering based on the number of recommended transactions and then performing classification calculations.
  • Clustering When determining the transaction limit for the second consensus round, if the proposal consensus fails, the data can be grouped based on the number of proposed transactions, so that the data within the same group has high similarity and the data between different groups has large differences. Then, a data processing method is used to classify and calculate the different groups to determine the limit.
  • a block proposal method in one embodiment of the present application may include the following steps:
  • Step S1010 Obtain multiple voting results generated by multiple blockchain nodes for the first block proposal in the first consensus round in the blockchain, where each voting result includes the number of recommended transactions, and the number of recommended transactions is determined based on the number of first proposal transactions in the first block proposal and the execution time of the first block proposal by the blockchain node that generates the voting result.
  • step S1010 is consistent with those of step S510 shown in FIG5 , and are not described again.
  • Step S1020 Generate a transaction limit for a second consensus round based on the number of recommended transactions included in each of the multiple voting results.
  • the second consensus round is the next consensus round after the first consensus round.
  • step S1020 is consistent with those of step S520 shown in FIG5 , and are not described again.
  • Step S1030 Pack the blockchain transactions in the local transaction pool according to the transaction quantity limit, and generate a second block proposal for voting by multiple blockchain nodes in the second consensus round in the blockchain.
  • step S1030 is consistent with those of step S530 shown in FIG5 , and are not described again.
  • Step S1040 broadcast the second block proposal in the blockchain.
  • step S1040 implementation details of step S1040 are consistent with those of step S540 shown in FIG5 , and are not described again.
  • Step S1050 Obtain the third block proposal generated by the master node
  • the third block proposal is a block proposal generated and packaged by the master node after the second block proposal, but it is not necessarily the next round of proposals after the second block proposal.
  • Step S1060 Execute the blockchain transaction in the third block proposal to obtain the execution result and execution duration of the third block proposal;
  • Step S1070 Determine the number of recommended transactions for the local node based on the execution result and execution time.
  • Step S1080 Generate a node voting result for the third block proposal based on the execution result of the third block proposal and the number of proposed transactions of the local node;
  • the node voting result (Node voting result) is generated by the local node based on the execution result of the third block proposal and the number of proposed transactions of the local node. It includes voting information, voting signature, number of proposed transactions, current block height, number of consensus rounds, and information signature, etc. It is used to broadcast in the blockchain and participate in the consensus on the third block proposal.
  • Step S1090 broadcast the node voting results in the blockchain.
  • the local node after broadcasting the second block proposal, switches from master node to slave node, while another node becomes the master node.
  • This master node then packages and generates the third block proposal.
  • the third block proposal follows the second block proposal, but is not necessarily the next round of proposals after it.
  • the local node executes the blockchain transactions in the third block proposal, obtaining the execution result and execution duration of the third block proposal. Subsequently, based on the execution result and execution duration, the local node determines the number of transactions recommended. Specifically, if the execution result is successful but the execution duration is short, the number of transactions in the recommended number of transactions can be increased.
  • the local node If the execution result is failed or the execution duration is long, the number of transactions in the recommended number of transactions can be decreased. Subsequently, the local node generates the node voting results for the third block proposal based on the execution result of the third block proposal and the number of transactions recommended by the local node.
  • Figure 11 is a schematic diagram of the node voting results in this embodiment of the present application. As shown in Figure 11, the node voting results are generally divided into two categories: yes votes and no votes. Both outcomes are identified by a corresponding identifier and accompanied by the local node's recommended transaction count. Finally, the local node broadcasts the node voting results on the blockchain.
  • the blockchain node after obtaining multiple voting results generated by multiple blockchain nodes for the first block proposal in the first consensus round for the first block proposal, the blockchain node will generate a transaction limit for the second consensus round based on the number of recommended transactions in each voting result.
  • the second consensus round is the next consensus round after the first consensus round, and when becoming a proposal node, it will package blockchain transactions into a new block proposal according to the determined transaction limit for the second consensus round, and broadcast it in the blockchain to generate a new block in the blockchain.
  • the number of transactions packaged for the next proposal is adjusted according to the suggestions of each node, so that the transactions included in the block proposal can be automatically adjusted during the execution result and execution time of the proposal, avoiding too many transactions in the block proposal causing execution timeout when verifying the proposal, and then preventing the proposal from failing due to execution timeout, which is beneficial to improving the operation efficiency of the blockchain.
  • the node in the process of generating the node voting result for the third block proposal based on the execution result of the third block proposal and the number of proposed transactions of the local node, the node will determine the voting information for the third block proposal based on the matching result between the execution result of the blockchain transaction in the third block proposal and the proposal result in the third block proposal. Then, the node signs the voting information based on the blockchain key of the local node to obtain a voting signature, and signs the number of proposed transactions based on the blockchain key of the local node to obtain an information signature. Finally, the node generates the node voting result for the third block proposal based on the voting information and voting signature, as well as the number of proposed transactions and the information signature.
  • a blockchain key is a key owned by a blockchain node and is used to sign important information such as voting information and the number of proposed transactions to ensure the security, authenticity, and integrity of information during transmission and storage, and to prevent information from being tampered with or forged.
  • a voting signature is the result of a local node signing the voting information for a third-block proposal using its own blockchain key. This signature ensures the authenticity and integrity of the voting information. Voting information, typically indicating approval or disapproval, is determined by matching the blockchain transaction execution results in the third-block proposal with the proposal results in the third-block proposal. It is used to express the node's attitude towards the third-block proposal and is a crucial component of the node's voting results.
  • the information signature is the result obtained by the local node signing the number of proposed transactions, the current block height in the blockchain, and the number of consensus rounds of the third block proposal based on its own blockchain key. It is used to prevent the forged sending of voting results and ensure the authenticity and validity of information such as the number of proposed transactions.
  • the current block height refers to the location identifier of the current block in the blockchain, representing the number of blocks from the blockchain's genesis block to the current block. This information is added when generating node voting results. It can be used to determine whether the voting results are issued for the current consensus round and prevent the forgery of voting results.
  • the voting information and the magnitude of the recommended transaction are signed separately, so that nodes that do not have the ability to provide the number of recommended transactions can still reach consensus based only on the voting information and the corresponding signatures, thereby improving the compatibility of the solution.
  • the node in the process of signing the number of proposed transactions according to the blockchain key of the local node and obtaining the information signature, the node will obtain the current block height in the blockchain and the consensus round number of the third block proposal; according to the blockchain key of the local node, the number of proposed transactions, the current block height and the number of consensus rounds are signed to obtain the information signature.
  • the node When generating the node voting results, the node will generate the node voting results for the third block proposal based on the voting information and voting signature, as well as the number of proposed transactions, the current block height and the number of consensus rounds and the information signature.
  • the consensus round number refers to the round number for voting and reaching consensus on different block proposals during the consensus process of the blockchain. It is used to identify which round of consensus is currently in. Adding this information when generating the node voting results helps the node judge the timeliness of the voting results and avoid being affected by forged voting results.
  • FIG 12 is a schematic diagram of the specific structure of the node voting results in the embodiment of the present application.
  • the current block height and consensus round number are further added to the node voting results, mainly used to prevent the forged sending of voting results.
  • the malicious node may collect the voting results of other nodes in the previous round, and then send the voting results of other nodes in the previous round in the next round of consensus, causing other nodes to mistakenly believe that it is the result sent by the original node in the current round and cause an error in the confirmation of the number of transactions.
  • the current block height and consensus round number in the node voting results can be used by the node to determine whether the voting results are issued for the current consensus round, thereby avoiding the influence of forged voting results and improving the security of the solution.
  • the node determines the candidate number of proposals for the local node based on the number of first-proposal transactions, the node capability parameter, and the execution duration, wherein the node capability parameter is determined based on the historical transaction execution results of the local node. If the execution result matches the proposal result in the third block proposal, the node uses the larger number of the candidate number of proposals and the number of first-proposal transactions as the number of proposed transactions for the local node. If the execution result does not match the proposal result in the third block proposal, the node uses the smaller number of the candidate number of proposals and the number of first-proposal transactions as the number of proposed transactions for the local node.
  • the node capability parameter is a parameter determined based on the local node's historical transaction execution results. It is used to determine the number of candidate proposals for the local node and can be updated based on the number of proposed transactions from other blockchain nodes.
  • the candidate suggested quantity is a value determined by the local node based on the number of first-proposal transactions, the node capability parameter, and the execution time. It is used to determine the number of suggested transactions for the local node.
  • the local node determines the candidate suggested number based on the node capability parameter determined by historical transactions.
  • the candidate suggested number can be (current number * X) / current time, where X is the node capability parameter.
  • the node capability parameter is determined based on the local node's historical transaction execution results, for example, based on the difference between the historical transaction execution and the current number and the number proposed by other nodes.
  • determining the candidate suggested number based on the node capability parameter determined by historical transaction execution results and then selecting the suggested transaction number based on the match between the execution result and the proposal result can ensure a higher degree of match between the determined suggested transaction number and the execution result, compared to directly determining the suggested transaction number based on the local node's computing power, thereby facilitating the accuracy of the determined suggested transaction number.
  • the node will also determine the baseline number based on the number of recommended transactions of other blockchain nodes in the multiple voting results generated by multiple blockchain nodes for the first block proposal in the first consensus round, and then update the node capability parameters of the local node based on the baseline number, the number of recommended transactions of the local node in the multiple voting results generated by multiple blockchain nodes for the first block proposal in the first consensus round, and the proposal execution time threshold in the blockchain.
  • the baseline quantity is a value determined by the number of transactions proposed by other blockchain nodes in the first consensus round, generated by multiple voting results for the first block proposal. It is used to update the node capacity parameters of the local node.
  • the proposal execution time threshold is a preset time limit in the blockchain that limits the total execution time of all transactions in a block proposal. If the execution time exceeds this threshold, the proposal may fail.
  • a blockchain node adjusts its node capability parameters based on the number of proposed transactions submitted by other nodes. Specifically, the local node determines a baseline number based on the number of proposed transactions submitted by other blockchain nodes in the voting results for the first block proposal generated by multiple blockchain nodes during the first consensus round. For example, if all other nodes propose 5,000 transactions based on the same number of transactions (e.g., 10,000), while the local node proposes 4,000 transactions, 5,000 can be used as the baseline number. It is understood that the baseline number can be the most frequent number of proposed transactions among the other blockchain nodes, but can also be determined using other methods, such as the mean or median. The local node then adjusts its node capability parameters based on the baseline number.
  • the local node can increase its current node capability parameters based on the ratio between the difference between the baseline number and the number of proposed transactions and the proposal execution time threshold.
  • the node capability parameter can be calculated as 4000*10*0.8/5000, where 10 is the proposal execution time threshold (i.e., 10 seconds), and 0.8 is the preset adjustment threshold. It is understood that the process of updating the local node's node capability parameters is typically performed after consensus is reached.
  • the local node updates its node capability parameters based on the number of recommended transactions from other nodes, thereby enabling timely adjustments to the number of recommended transactions generated by the local node. This prevents the number of recommended transactions from being too high or too low, which could affect the number of transactions packaged in the block, and improves the rationality of the number of transactions in the block.
  • FIG. 13 is a schematic flowchart of the overall process of block proposal processing in the embodiment of the present application.
  • the current consensus node will obtain the transactions to be packaged from the transaction pool, execute the obtained transactions, and thus generate the block proposal for this round of consensus.
  • the current master node then broadcasts the proposal to other nodes in the blockchain.
  • Other nodes are mainly divided into ordinary nodes and next-round master nodes, but the processing process of these two types of nodes in the current round of consensus is the same. Taking ordinary nodes as an example, they will parse the broadcast network information to obtain the broadcast block proposal.
  • Network information In the blockchain network, the information transmitted when nodes communicate, including block proposals, voting results and other data. Ordinary nodes can obtain broadcast block proposals and other content by parsing the broadcast network information.
  • the node then verifies the proposal itself. If the verification fails, a negative vote is generated. If the verification passes, the node executes all transactions in the proposal and records the number of completed transactions. It then generates a proposed number of transactions based on the total execution time and the number of completed transactions. The node verifies the transaction execution results against the proposal results. If the verification passes, a positive vote is generated; if it fails, a negative vote is generated. Both votes are appended with the number of proposed transactions. The node then broadcasts the voting results to other nodes in the blockchain. Each node in the blockchain calculates the maximum number of transactions to be packaged in the next round based on the number of proposed transactions in the vote. After the current round of consensus is completed, the master node in the next round will retrieve the transactions to be packaged from the transaction pool according to the number determined in the previous round, execute the acquired transactions, and generate the block proposal for the next round of consensus.
  • Proposal object a block proposal is an object generated by the master node by packaging blockchain transactions. It is used for consensus between blockchain nodes. Ordinary nodes will verify the proposal object itself to determine whether it meets the requirements.
  • Ordinary node In the consensus process of the blockchain, except for the master node and the next round master node, it will receive the block proposal broadcast by the master node during the current round of consensus, verify and execute the proposal, generate and broadcast the voting results based on the execution results, and generate the number of transaction suggestions based on the total execution time and the number of completed transactions.
  • Number of completed transactions The number of transactions successfully completed by the node when executing the blockchain transactions in the block proposal.
  • the node will generate the number of transaction proposals based on this number and the total execution time.
  • FIG14 schematically shows a block diagram of the block proposal apparatus in an embodiment of the present application.
  • the block proposal apparatus 1400 may mainly include:
  • an acquisition module 1410 configured to acquire a plurality of voting results generated by a plurality of blockchain nodes in a first consensus round in a blockchain for a first block proposal, wherein each voting result includes a number of suggested transactions, where the number of suggested transactions is determined based on the number of first proposal transactions in the first block proposal and an execution time of the first block proposal by the blockchain node generating the voting result;
  • a generating module 1420 is configured to generate a transaction limit for a second consensus round based on the number of proposed transactions included in each of the plurality of voting results, where the second consensus round is the next consensus round after the first consensus round;
  • the packaging module 1430 is configured to package the blockchain transactions in the local transaction pool according to the transaction quantity limit and generate a second block proposal for voting by multiple blockchain nodes in the second consensus round of the blockchain;
  • the broadcast module 1440 is configured to broadcast the second block proposal in the blockchain.
  • the generation module 1420 is specifically configured to: determine the proposal consensus result for the first block proposal based on the multiple voting results generated by multiple blockchain nodes for the first block proposal in the first consensus round; based on the proposal consensus result, obtain the voting result corresponding to the proposal consensus result from the multiple voting results generated by multiple blockchain nodes for the first block proposal in the first consensus round as the candidate voting result; based on the number of recommended transactions in the candidate voting results, generate a transaction number limit for the second consensus round, and the second consensus round is the next consensus round of the first consensus round.
  • the generation module 1420 is specifically configured as follows: if the proposal consensus result is that the proposal is successful, then the voting result of voting in favor from the multiple voting results generated by multiple blockchain nodes in the first consensus round for the first block proposal is used as the candidate voting result; if the proposal consensus result is that the proposal fails, then the voting result of voting against from the multiple voting results generated by multiple blockchain nodes in the first consensus round for the first block proposal is used as the candidate voting result.
  • the generation module 1420 is specifically configured as follows: if the proposal consensus result is that the proposal is successful, the number of first proposal transactions in the first block proposal is obtained; if the number of first proposal transactions is greater than or equal to the number of recommended transactions in the candidate voting result, the number of first proposal transactions is used as the transaction number limit for the second consensus round; if the number of first proposal transactions is less than the number of recommended transactions in the candidate voting result, the transaction number limit for the second consensus round is generated according to the average of the number of first proposal transactions and the number of selected recommended transactions.
  • the candidate voting results include multiple voting results generated by multiple blockchain nodes for the first block proposal in the first consensus round; the generation module 1420 is specifically configured to: if the number of first proposal transactions is less than the number of recommended transactions in the candidate voting results, then obtain the block transaction number threshold of the blockchain; if the number of recommended transactions of any voting result in the candidate voting results is greater than the block transaction number threshold, then delete the voting result from the candidate voting results; based on the average of the number of first proposal transactions and the number of recommended transactions of each voting result in the candidate voting results, generate the transaction number limit for the second consensus round.
  • the generation module 1420 is specifically configured as follows: if the proposal consensus result is a proposal failure, the number of recommended transactions in the candidate voting results is obtained; based on the sum of the number of recommended transactions in the candidate voting results and the number of candidate voting results, the transaction number limit of the second consensus round is determined.
  • the broadcast module 1440 is further configured to: obtain the third block proposal generated by the master node; execute the blockchain transaction in the third block proposal to obtain the execution result and execution duration of the third block proposal; determine the number of recommended transactions of the local node based on the execution result and execution duration; generate the node voting result for the third block proposal based on the execution result of the third block proposal and the number of recommended transactions of the local node; and broadcast the node voting result in the blockchain.
  • the broadcast module 1440 is specifically configured to: determine the voting information for the third block proposal based on the matching result between the execution result of the blockchain transaction in the third block proposal and the proposal result in the third block proposal; sign the voting information according to the blockchain key of the local node to obtain a voting signature; sign the number of proposed transactions according to the blockchain key of the local node to obtain an information signature; generate the node voting result for the third block proposal based on the voting information and the voting signature and the number of proposed transactions and the information signature.
  • the broadcast module 1440 is specifically configured to: obtain the current block height in the blockchain and the number of consensus rounds of the third block proposal; sign the number of proposed transactions, the current block height and the number of consensus rounds according to the blockchain key of the local node to obtain an information signature; generate the node voting result for the third block proposal based on the voting information and the voting signature, as well as the number of proposed transactions, the current block height and the number of consensus rounds and the information signature.
  • the broadcast module 1440 is specifically configured to: determine the number of candidate suggestions for the local node based on the number of first proposal transactions, the node capability parameter and the execution time, wherein the node capability parameter is determined based on the historical transaction execution results of the local node; if the execution result matches the proposal result in the third block proposal, the larger number between the candidate suggestion number and the first proposal transaction number is used as the recommended transaction number of the local node; if the execution result does not match the proposal result in the third block proposal, the smaller number between the candidate suggestion number and the first proposal transaction number is used as the recommended transaction number of the local node.
  • the broadcast module 1440 is specifically configured to: determine the baseline number based on the number of recommended transactions of other blockchain nodes in the multiple voting results generated by multiple blockchain nodes for the first block proposal in the first consensus round; update the node capability parameters of the local node based on the baseline number, the number of recommended transactions of the local node in the multiple voting results generated by multiple blockchain nodes for the first block proposal in the first consensus round, and the proposal execution time threshold in the blockchain.
  • the block proposal method, apparatus, electronic device, computer-readable medium, and computer program product provided herein involve a blockchain node in a blockchain obtaining multiple voting results generated by multiple blockchain nodes for a first block proposal during a first consensus round.
  • Each voting result includes a proposed transaction number, which is determined based on the number of first proposal transactions in the first block proposal and the execution time of the first block proposal by the blockchain node generating the voting result.
  • a transaction limit for the second consensus round is generated.
  • the second consensus round is the consensus round following the first consensus round.
  • blockchain transactions in the local transaction pool are packaged to generate a second block proposal.
  • the second block proposal is broadcasted on the blockchain, and the second block proposal is used to instruct multiple blockchain nodes in the second consensus round to vote.
  • the number of transactions packaged for the next proposal can be adjusted based on the suggestions of each node during the consensus process, automatically adjusting the transactions included in the block proposal. This prevents timeouts during proposal verification due to excessive transactions, prevents proposal failures, and improves blockchain operational efficiency.
  • the blockchain nodes determine a proposal consensus result for the first block proposal based on the multiple voting results generated by multiple blockchain nodes for the first block proposal in the first consensus round. Based on the proposal consensus result, the nodes then obtain a voting result corresponding to the proposal consensus result from the multiple voting results generated by multiple blockchain nodes for the first block proposal in the first consensus round as a candidate voting result. Furthermore, based on the number of proposed transactions in the candidate voting results, the nodes generate a transaction limit for the second consensus round. This allows the correct voting results to have a greater impact on the factors determining the transaction limit for the second consensus round, thereby improving the accuracy of the determined transaction limit.
  • the blockchain nodes use the voting results of the multiple voting results for the first block proposal generated by multiple blockchain nodes in the first consensus round as the candidate voting results.
  • the consensus result for a proposal is a failure
  • the voting results of the multiple voting results for the first block proposal generated by multiple blockchain nodes in the first consensus round as the candidate voting results. This prevents the number of proposals submitted by nodes with incorrect judgments from affecting the specified number, reduces the probability of malicious data affecting the transaction number determination process, and improves the security of the blockchain system.
  • the blockchain node obtains the number of transactions in the first proposal in the first block proposal. If the number of transactions in the first proposal is greater than or equal to the number of transactions recommended in the candidate voting result, the number of transactions in the first proposal is used as the transaction limit for the second consensus round. In this way, when the slave node approves the number of transactions packaged by the master node, the number of transactions in the first proposal is directly used as the transaction limit for the next round.
  • the blockchain node If the number of transactions in the first proposal is less than the number of transactions recommended in the candidate voting results, the blockchain node generates a transaction limit for the second consensus round based on the average of the number of transactions in the first proposal and the number of transactions selected. This allows the node to promptly increase the transaction limit for block proposals when the number of transactions in the master node is low, avoiding the waste of consensus processing resources caused by too few transactions in the block, and improving the resource utilization of the solution.
  • the candidate voting results include multiple voting results generated by multiple blockchain nodes for the first block proposal during the first consensus round. If the number of transactions in the first proposal is less than the number of suggested transactions in the candidate voting results, the blockchain node obtains the blockchain's block transaction threshold. If the number of suggested transactions for any voting result in the candidate voting results exceeds the block transaction threshold, that voting result is removed from the candidate voting results.
  • the transaction limit for the second consensus round is then generated based on the average of the number of transactions in the first proposal and the number of suggested transactions for each voting result in the candidate voting results. This prevents consensus failures caused by proposal execution timeouts due to an excessive number of transactions in the block proposal, thereby improving the stability of the solution.
  • the blockchain node obtains the number of suggested transactions from the candidate voting results and determines the transaction limit for the second consensus round based on the sum of the number of suggested transactions in the candidate voting results and the number of candidate voting results. This allows for timely reduction of excessive transaction counts or excessive execution times when a proposal fails, preventing subsequent consensus failures and improving the consensus success rate by determining the limit based solely on the number of suggested transactions from the failed candidate voting results.
  • the blockchain node After broadcasting the second block proposal to the blockchain, the blockchain node retrieves the third block proposal generated by the master node, executes the blockchain transactions in the third block proposal, and obtains the execution result and execution duration of the third block proposal. Based on the execution result and execution duration, the node node determines the number of transactions recommended for the local node. Based on the execution result and the number of transactions recommended by the local node, the node voting result for the third block proposal is generated and broadcast to the blockchain. By increasing the number of recommended transactions when voting in favor, an excessively low transaction count can be corrected in a timely manner, preventing malicious nodes from causing a decrease in blockchain transaction processing efficiency and improving the security of the solution.
  • the blockchain node determines the voting information for the third-block proposal. Using the local node's blockchain key, the node signs the voting information to obtain a voting signature. Using the local node's blockchain key, the node signs the number of proposed transactions to obtain a message signature. Based on the voting information and voting signature, as well as the number of proposed transactions and message signature, the node voting result for the third-block proposal is generated. Signing the voting information and the number of proposed transactions separately in the node voting result allows nodes that are unable to provide the number of proposed transactions to still reach consensus based on the voting information and corresponding signatures, improving the solution's compatibility.
  • the blockchain node obtains the current block height and the number of consensus rounds for the third block proposal from the blockchain. Using the local node's blockchain key, it signs the proposed transaction count, current block height, and consensus round count to obtain a message signature. Based on the voting information and voting signature, along with the proposed transaction count, current block height, consensus round count, and message signature, the node voting result for the third block proposal is generated. Adding the current block height and consensus round count to the node voting result prevents forged voting results from being sent, preventing nodes from incorrectly confirming the transaction count due to forged voting results, and improving the security of the solution.
  • the blockchain node determines the number of candidate proposals for the local node based on the number of transactions in the first proposal, the node's capability parameters, and the execution duration.
  • the node capability parameters are determined based on the local node's historical transaction execution results. If the execution result matches the result of the proposal in the third block, the larger of the candidate proposal number and the number of transactions in the first proposal is used as the local node's proposed transaction number. Compared to directly determining the number of proposed transactions based on the local node's computing power, this method ensures a closer match between the determined number of proposed transactions and the execution result, improving the accuracy of the number of proposed transactions.
  • the blockchain node will use the smaller of the candidate proposal number and the first proposal transaction number as the local node's recommended transaction number. This further improves the method of determining the recommended transaction number based on the execution result, making the recommended transaction number more consistent with actual execution.
  • the blockchain node determines a baseline number of transactions based on the number of transactions recommended by other blockchain nodes in the multiple voting results generated by multiple blockchain nodes for the first block proposal during the first consensus round.
  • the node capacity parameters of the local node are updated based on the baseline number, the number of transactions recommended by the local node in the multiple voting results generated by multiple blockchain nodes for the first block proposal during the first consensus round, and the proposal execution time threshold in the blockchain.
  • FIG15 shows a schematic structural diagram of a computer system suitable for implementing an electronic device according to an embodiment of the present application.
  • computer system 1500 includes a central processing unit (CPU) 1501, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 1502 or programs loaded from storage 1508 into random access memory (RAM) 1503.
  • RAM 1503 also stores various programs and data required for system operation.
  • CPU 1501, ROM 1502, and RAM 1503 are interconnected via bus 1504.
  • An input/output (I/O) interface 1505 is also connected to bus 1504.
  • the following components are connected to the I/O interface 1505: an input section 1506 including a keyboard, a mouse, and the like; an output section 1507 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and a speaker; a storage section 1508 including a hard disk and the like; and a communication section 1509 including a network interface card such as a LAN (Local Area Network) card or a modem.
  • the communication section 1509 performs communication processing via a network such as the Internet.
  • a drive 1510 is also connected to the I/O interface 1505 as needed.
  • Removable media 1511 such as a magnetic disk, an optical disk, a magneto-optical disk, or a semiconductor memory, is installed in the drive 1510 as needed, so that computer programs read therefrom can be installed into the storage section 1508 as needed.
  • an embodiment of the present application includes a computer program product comprising a computer program carried on a computer-readable medium, the computer program comprising program code for executing the methods shown in the flow charts.
  • the computer program can be downloaded and installed from a network via the communication section 1509, and/or installed from a removable medium 1511.
  • the central processing unit (CPU) 1501 the various functions defined in the system of the present application are executed.
  • the computer-readable medium shown in the embodiments of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above.
  • the computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination of the above.
  • Computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
  • a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or device.
  • a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof.
  • a computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
  • Program code embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, or any suitable combination thereof.
  • each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the above-mentioned module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function.
  • the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved.
  • each box in the block diagram or flowchart, and the combination of the boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
  • the technical solution according to the embodiments of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the embodiments of the present application.
  • a non-volatile storage medium which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.
  • a computing device which can be a personal computer, a server, a touch terminal, or a network device, etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Business, Economics & Management (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Accounting & Taxation (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Strategic Management (AREA)
  • Computing Systems (AREA)
  • General Business, Economics & Management (AREA)
  • Finance (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种区块提案方法,由区块链中的区块链节点执行,包括:获取区块链中第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果,每个投票结果包含建议事务数量,建议事务数量根据第一区块提案中的第一提案事务数量、及产生投票结果的区块链节点执行第一区块提案的执行时长确定(S510);根据多个投票结果各自包含的建议事务数量,生成第二共识轮次的事务数量限额,第二共识轮次是第一共识轮次的下一共识轮次(S520);按照事务数量限额,将本地事务池中的区块链事务打包,生成供区块链中第二共识轮次内多个区块链节点投票的第二区块提案(S530);及在区块链中广播第二区块提案(S540)。

Description

区块提案方法、装置、电子设备和可读介质
相关申请
本申请要求2024年04月08日申请的,申请号为202410418430.9,名称为“区块提案方法、装置、电子设备和可读介质”的中国专利申请的优先权,在此将其全文引入作为参考。
技术领域
本申请涉及计算机技术领域,尤其涉及区块链技术领域,特别涉及一种区块提案方法、装置、电子设备和可读介质。
背景技术
随着区块链技术的发展,越来越多的业务系统开始使用区块链。在区块链中,区块链节点会将多笔区块链事务打包成一个提案来在区块链节点之间进行共识,共识通过后才会在区块链中生成区块。
在相关技术中,区块链节点会按照预设的区块事务数量上限和区块执行时长上限来打包区块链以进行提案。
然而,在此类技术中,提案过程会按照区块执行时长上限尽量多打包事务,使得提案区块的执行时长趋近于执行时长上限,而这可能会导致其他节点在验证提案时的执行时长超过区块执行时长上限而反对共识,进而造成提案失败,影响区块链的运行效率。
发明内容
本申请提供一种区块提案方法、装置、电子设备和可读介质。
根据本申请实施例的一个方面,提供一种区块提案方法,由区块链中的区块链节点执行,包括:
获取区块链中第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果,每个投票结果包含建议事务数量,所述建议事务数量根据所述第一区块提案中的第一提案事务数量、及产生所述投票结果的区块链节点执行所述第一区块提案的执行时长确定;
根据所述多个投票结果各自包含的建议事务数量,生成第二共识轮次的事务数量限额,所述第二共识轮次是所述第一共识轮次的下一共识轮次;
按照所述事务数量限额,将本地事务池中的区块链事务打包,生成供所述区块链中第二共识轮次内多个区块链节点投票的第二区块提案;及
在所述区块链中广播所述第二区块提案。
根据本申请实施例的一个方面,提供一种区块提案装置,包括:
获取模块,配置成获取区块链中第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果,每个投票结果包含建议事务数量,所述建议事务数量根据所述第一区块提案中的第一提案事务数量、及产生所述投票结果的区块链节点执行所述第一区块提案的执行时长确定;
生成模块,配置成根据所述多个投票结果各自包含的建议事务数量,生成第二共识轮次的事务数量限额,所述第二共识轮次是所述第一共识轮次的下一共识轮次;
打包模块,配置成按照所述事务数量限额,将本地事务池中的区块链事务打包,生成供所述区块链中第二共识轮次内多个区块链节点投票的第二区块提案;及
广播模块,配置成在所述区块链中广播所述第二区块提案。
根据本申请实施例的一个方面,提供一种电子设备,该电子设备包括:处理器;以及存储器,用于存储处理器的可执行指令;其中,该处理器配置为经由执行可执行指令来执行如以上技术方案中的区块提案方法。
根据本申请实施例的一个方面,提供一种计算机可读存储介质,其上存储有计算机程序,当该计算机程序被处理器执行时实现如以上技术方案中的区块提案方法。
根据本申请实施例的一个方面,提供了一种计算机程序产品或计算机程序,该计算机程序产品或计算机程序包括计算机指令,该计算机指令存储在计算机可读存储介质中。电子设备的处理器从计算机可读存储介质读取该计算机指令,处理器执行该计算机指令,使得该电子设备执行上述各种可选实现方式中提供的区块提案方法。
本申请的一个或多个实施例的细节在下面的附图和描述中提出。本申请的其它特征、目的和优点将从说明书、附图以及权利要求书变得明显。
附图说明
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本申请的实施例,并与说明书一起用于解释本申请的原理。显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是本申请技术方案在一个应用场景中的示例性系统构架示意图。
图2为本申请实施例中区块提案的总体情况示意图。
图3为本申请实施例中区块链网络的示意图。
图4为本申请实施例中区块链网络中区块的示意图。
图5示出了根据本申请的一个实施例的区块提案方法的流程图。
图6示出了根据本申请的一个实施例的区块提案方法的流程图。
图7为本申请实施例中生成第二共识轮次的事务数量限额的逻辑示意图。
图8为本申请实施例中生成第二共识轮次的事务数量限额另一逻辑示意图。
图9为本申请实施例中生成第二共识轮次的事务数量限额的另一逻辑示意图。
图10示出了根据本申请的一个实施例的区块提案方法的流程图。
图11为本申请实施例中节点投票结果的示意图。
图12为本申请实施例中节点投票结果具体结构的示意图。
图13为本申请实施例中区块提案处理整体流程的示意性流程图。
图14示意性地示出了本申请实施例中区块提案装置的组成框图。
图15示出了适于用来实现本申请实施例的电子设备的计算机系统的结构示意图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
此外,所描述的特征、结构或特性可以以任何合适的方式结合在一个或更多实施例中。在下面的描述中,提供许多具体细节从而给出对本申请的实施例的充分理解。然而,本领域技术人员将意识到,可以实践本申请的技术方案而没有特定细节中的一个或更多,或者可以采用其它的方法、组元、装置、步骤等。在其它情况下,不详细示出或描述公知方法、装置、实现或者操作以避免模糊本申请的各方面。
本申请实施例中,术语“模块”或“单元”是指有预定功能的计算机程序或计算机程序的一部分,并与其他相关部分一起工作以实现预定目标,并且可以通过使用软件、硬件(如处理电路或存储器)或其组合来全部或部分实现。同样的,一个处理器(或多个处理器或存储器)可以用来实现一个或多个模块或单元。此外,每个模块或单元都可以是包含该模块或单元功能的整体模块或单元的一部分。
附图中所示的方框图仅仅是功能实体,不一定必须与物理上独立的实体相对应。即,可以采用软件形式来实现这些功能实体,或在一个或多个硬件模块或集成电路中实现这些功能实体,或在不同网络和/或处理器装置和/或微控制器装置中实现这些功能实体。
附图中所示的流程图仅是示例性说明,不是必须包括所有的内容和操作/步骤,也不是必须按所描述的顺序执行。例如,有的操作/步骤还可以分解,而有的操作/步骤可以合并或部分合并,因此实际执行的顺序有可能根据实际情况改变。
应理解,本申请的方案应用在区块链的共识节点进行提案的过程中,并且具体应用在将区块链事务打包成提案的场景。区块链系统实际上是一个分布式系统,但它又与普通的分布式系统不同,在区块链系统中,每个共识节点会对它都要达成一致的区块进行共识,只有共识一致后,才会得到整个区块链系统的认可,也就是区块链共识。在一个区块中往往会包含很多笔事务,一般而言,在允许的范围内,事务量越大其实越好,这是因为区块除了存储事务外,还会存储区块头、节点投票等信息,而区块头和节点投票等信息往往大小基本是固定的,那么这个区块中存储的事务数量越多,对应的存储就越省空间。这个允许范围一般包括两部分,一个区块链事务的最大数量和整个区块中事务的最长执行时间。
区块头(Block header)是区块链中每个区块的一部分,包含输入信息特征值、版本号、时间戳、难度值以及父区块的区块头特征值等信息,用于保证区块链中每个区块中存储的区块数据均与父区块中存储的区块数据存在关联,确保区块中输入信息的安全性。
区块链事务(Blockchain transaction)是在区块链系统中区块链节点之间进行数据的传输、处理、验证等一系列交互活动的操作单元,区块链节点会将多笔这样的事务打包成一个提案,在区块链节点间进行共识,共识通过后在区块链中生成包含这些事务信息的区块。该操作存在数量上限和执行时长上限等限制,并且在区块链的共识过程中,区块链节点会根据提案中事务的执行情况,对下一轮共识提案中所要包含的事务数量提出建议,以动态调整每个区块中事务的数量,从而提高区块链的运行效率。
最大数量(Maximum quantity):在确定下次打包事务时,根据各个节点投票中的建议事务数量计算得出的一个数量上限值,下一轮主节点会按照该数量上限从事务池中获取要打包的事务。
如果一个区块链中事务数量非常大,且不做控制,因为事务是需要执行的,那么会导致节点计算资源过大,整个区块链性能受影响;类似的,如果一个区块的执行时间不做控制,也会导致整个区块链很长时间无法达成共识,从而使得区块链性能受影响。
那么目前业内通常的解决方案,就是为这两个参数设置一个上限,数量上限一般会根据每秒事务数和业务需求来设置,而时间往往会采用固定的方式,例如10秒。事务数(Transaction volume):指在区块链系统中,单位时间内发生的事务(或交易)的数量,通常用于衡量区块链系统的处理能力和业务繁忙程度,数量上限一般会根据每秒事务数和业务需求来设置。
从时间角度来看,则会存在一定的风险,为了更高的性能,对于提案的主节点而言,其肯定会尽量打包更多的事务进提案,这样执行时间就较长,但肯定会低于10秒(例如9.8秒),然而从节点则不一样,它也会执行这个区块中的所有事务,一旦受到服务器性能和资源占用等原因的影响而造成执行时间超过10秒,从节点会认为主节点的提案有问题投反对票,进而有可能会导致本轮共识达不成一致而需要重新进行共识,影响了区块链的整体性能。
基于此,本申请实施例的技术方案提出了一种区块提案方案。具体地,如图1所示,根据本申请实施例的应用于区块提案方案的系统架构可以包括四个区块链节点构成的区块链网络。实现区块链节点的电子设备可以包括智能手机、平板电脑、笔记本电脑、智能语音交互设备、智能家电、车载终端、飞行器等等。实现区块链节点的电子设备还可以是提供各种服务的服务器,其可以是独立的物理服务器,也可以是多个物理服务器构成的服务器集群或者分布式系统,还可以是提供云服务、云数据库、云计算、云函数、云存储、网络服务、云通信、中间件服务、域名服务、安全服务、CDN(Content Delivery Network,内容分发网络)以及大数据和人工智能平台等基础云计算服务的云服务器。区块链节点之间可以存在通信链路的各种连接类型的通信介质,例如可以是有线通信链路或者无线通信链路。
根据实现需要,本申请实施例中的系统架构可以具有任意数目的终端设备和服务器。例如,实现区块链节点的电子设备可以是由多个服务器设备组成的服务器群组。另外,本申请实施例提供的技术方案可以应用于任意的区块链节点,或者可以由多个区块链节点共同实施,本申请对此不做特殊限定。
如图1所示,一个区块链节点作为区块链中的主节点110进行提案。可以理解的是,主节点可以是区块链的任意一个共识节点,并且区块链中的共识节点通常会按照预定的规则轮流成为主节点来进行提案,主节点之外的其他共识节点则成为从节点,从节点根据主节点的提案进行投票来进行共识,主节点确认在达成共识后通知各个从节点将新区块上链。在本申请的一个实施例中,区块链中的主节点110会向从节点120发送区块提案。而从节点在向主节点110发送对区块提案的投票时,从节点120也会关于下一轮提案中打包事务数量提供建议数量。所有从节点120都会进行投票以及提供建议数量。主节点110在会根据从节点120提供的建议来确定下一轮要打包的事务数量。并且在下一轮提案时按照确定的数量进行打包。
请参阅图2,图2为本申请实施例中区块提案的总体情况示意图。如图2所示,主节点会打包一笔事务(10000笔)并执行,形成区块提案。假定主节点执行该区块提案中所有事务的时间为9.8秒。区块提案会被广播到区块链中的从节点。节点2、节点3和节点4会验证接收到的提案。每个节点都会执行所接收到的区块提案中的所有事务,并基于执行结果确定投票内容,例如根据所有事务执行成功或者失败来对区块进行赞同或者反对的投票,同时,节点还会统计执行提案中所有事务的执行时长以及执行的超时情况,假定一个从节点的总执行时间为10.2秒,则由于事务超时,该节点的投票内容会是反对票。节点还会根据执行时长与提案中所包含的事务的数量来生成一个自己建议的事务数量。例如,由于执行超时,从节点会建议将事务数量设置为5000笔),从节点会在对提案的投票信息中附加自己建议的事务数量。从节点的投票信息会被广播给其他节点。区块链中的所有节点都会收集其他节点关于该提案的投票信息,并根据所收集到的投票信息判断第二轮投票中是否赞成区块上链。在第二轮投票中,如果是大多数节点都不赞成区块上链的情况下,各个节点也会投票不赞成提交区块。随后,各个节点会收集其他节点对第二轮投票的投票信息,从未最终判断是否提交区块,同时也会根据各个从节点建议的事务数量,确定新的提案事务数量限制。在下一轮共识中,成为主节点的节点会按照其所确定的提案事务数量限制来打包事务进行提案,例如,多数节点建议将事务数量设置为5000笔,则在下一轮的提案中,主节点会将5000笔事务打包成提案来进行提案流程。可以理解,大多数区块在执行5000笔事务的提案时仍然超时,则经过上述的投票和重新确定事务数量过程,提案中的事务数量会进一步减少,而如果大多数节点在执行5000笔事务时有较多的处理能力空闲,则可能会通过上述过程提高事务数量。
区块链是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链本质上是一个去中心化的数据库,是一串使用密码学方法相关联产生的数据块(即区块),每一个数据块包含了一批次网络事务的信息,用于验证其信息的有效性(防伪)和生成下一个区块。区块链是由区块链网络中的节点共同维护的。比如,在图3所示的区块链网络中,可以包括多个节点301,多个节点301可以是形成区块链网络的各个客户端。每个节点301在进行正常工作可以接收到输入信息,并基于接收到的输入信息维护该区块链网络内的共享数据。为了保证区块链网络内的信息互通,区块链网络中的每个节点之间可以存在信息连接,节点之间可以通过上述信息连接进行信息传输。例如,当区块链网络中的任意节点接收到输入信息时,区块链网络中的其它节点便根据共识算法获取该输入信息,将该输入信息作为共享数据进行存储,使得区块链网络中全部节点上存储的数据均一致。共识算法(Consensus algorithm)是指在区块链网络中,多个节点之间针对区块提案达成共识的算法,通过该算法,节点可以获取输入信息并将其作为共享数据进行存储,使得区块链网络中全部节点上存储的数据均一致。
对于区块链网络中的每个节点,均具有与其对应的节点标识,而且区块链网络中的每个节点均可以存储有其它节点的节点标识,以便后续根据其它节点的节点标识,将生成的区块广播至区块链网络中的其它节点。每个节点中可维护一个节点标识列表,将节点名称和节点标识对应存储至该节点标识列表中。其中,节点标识可为IP(Internet Protocol,网络之间互联的协议)地址以及其他任一种能够用于标识该节点的信息。
节点标识列表(Node identification list):区块链网络中每个节点维护的一个列表,用于将节点名称和节点标识对应存储,节点标识可为IP(Internet Protocol,网络之间互联的协议)地址以及其他任一种能够用于标识该节点的信息,以便节点后续根据其它节点的节点标识,将生成的区块广播至区块链网络中的其它节点。
区块链网络中的每个节点均存储一条相同的区块链。区块链由多个区块组成,参见图4所示,区块链由多个区块组成,创始块包括区块头和区块主体,区块头中存储有输入信息特征值、版本号、时间戳和难度值等,区块主体中存储有输入信息;创始块的下一区块以创始块为父区块,下一区块中同样包括区块头和区块主体,区块头中存储有当前区块的输入信息特征值、父区块的区块头特征值、版本号、时间戳和难度值等,并以此类推,使得区块链中每个区块中存储的区块数据均与父区块中存储的区块数据存在关联,保证了区块中输入信息的安全性。
创始块(Genesis block)是区块链中的第一个区块,包含区块头和区块主体,区块头中存储有输入信息特征值、版本号、时间戳和难度值等,区块主体中存储有输入信息,是后续区块的基础,后续区块以此为父区块依次生成。
父区块(Parent block):在区块链中,每个区块都有一个前序区块,该前序区块即为当前区块的父区块。每个区块的区块头中会存储父区块的区块头特征值,使得区块链中每个区块中存储的区块数据均与父区块中存储的区块数据存在关联,保证了区块中输入信息的安全性。
主节点110和从节点120所获得的区块链数据是可以如图4所示的区块结构。可以理解的是,虽然示出了3个区块,但主节点110和从节点120可以一次获得更多或者更少的区块,或者一次性获得区块链中的所有区块。
在本申请的实施例中,建议事务数量的相关信息可以以区块链事务的形式保存在图4中所示出的区块链结构的区块主体中,并且随着区块一起在节点之间进行共识以及在区块链中上链。
图5示出了根据本申请的一个实施例的区块提案方法的流程图,该区块提案方法可以由具有计算处理功能的设备来执行,比如可以是区块链节点的计算设备。参照图5所示,该区块提案方法至少包括步骤S510至步骤S540,详细介绍如下:
步骤S510,获取区块链中第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果,每个投票结果包含建议事务数量,建议事务数量根据第一区块提案中的第一提案事务数量、及产生投票结果的区块链节点执行第一区块提案的执行时长确定。
第一共识轮次(First consensus round),是在区块链的共识过程中针对第一区块提案进行投票和达成共识的轮次。在执行步骤S510时,第一共识轮次为当前共识轮次。
第二共识轮次(Second consensus round)是第一共识轮次的下一共识轮次,在该轮次中,主节点会按照上一轮确定的第二共识轮次的事务数量限额来打包区块链事务进行提案。
第一区块提案(First block proposal)是当前共识轮次(第一共识轮次)的主节点将区块链事务打包生成的区块提案,用于在区块链节点之间进行共识。
事务(Transaction)在区块链场景下,是区块链节点之间进行数据的传输、处理、验证等一系列交互活动的操作单元,区块链节点会将多笔这样的事务(或交易)打包成一个提案,在区块链节点间进行共识,共识通过后在区块链中生成包含这些事务(或交易)信息的区块。
建议事务数量(Suggested transaction quantity)是指根据第一区块提案中的第一提案事务数量、及产生投票结果的区块链节点执行第一区块提案的执行时长确定的一个数量值,该数量值表示投票节点根据其对第一区块提案执行情况对下一轮共识提案中所要包含的事务数量提出的建议。
第一提案事务数量(First proposed transaction quantity)是指第一区块提案打包时所采用的事务数量。
当前的区块链节点(即当前执行区块提案方法的区块链节点)在第一共识轮次中是从节点,其会从区块链中的各个节点接收第一区块提案的第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果。第一区块提案是当前共识轮次的主节点打包生成的区块。可以理解,第一区块提案打包是时所采用的事务数量限制也可以是按照本申请的方案确定的。投票结果是区块链中的各个节点基于对第一区块提案的校验和执行结果所确定的,其中会包含节点对第一区块提案的投票内容,通常为赞成或者反对,以及建议事务数量。建议事务数量根据第一区块提案中的第一提案事务数量、及产生投票结果的区块链节点执行第一区块提案的执行时长确定,其表示投票节点根据其对第一区块提案执行情况对下一轮共识提案中所要包含的事务数量提出的建议。可以理解,投票节点如果发现第一区块提案执行超时,则所确定的建议事务数量会比第一提案事务数量更少,而如果投票节点在执行第一区块提案后发现执行时长距离预设的最大时长较远,则会提出相较于第一提案事务数量更多的建议事务数量。需要强调的是,本地节点所获得的第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果不一定来自于区块链中的所有节点,而是只要获得的投票数量满足区块链的共识策略中确定共识结果的条件即可。即,如果共识条件要求有一半的节点赞成就可以达成共识,则本地节点只要获得一半的赞成票或者反对票就可以确定共识结果,并执行本申请的方案。本申请中多个可以是至少两个。
步骤S520,根据多个投票结果各自包含的建议事务数量,生成第二共识轮次的事务数量限额,第二共识轮次是第一共识轮次的下一共识轮次。
事务数量限额(Transaction quantity limit)是指在某个共识轮次中,主节点进行提案时所采用的事务数量的限制值,该值由上一轮共识中多个区块链节点针对上一区块提案产生的投票结果中的建议事务数量生成。
本地节点会根据第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中的建议事务数量生成第二共识轮次的事务数量限额,第二共识轮次是第一共识轮次的下一共识轮次。第二共识轮次的事务数量限额会被用作下一轮共识中的主节点进行提案时的事务数量限制。在确定第二共识轮次的事务数量限额时,可以先根据预设的生成策略从第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中选择出一部分建议事务数量,例如在执行时长比预设时长短时选择比第一提案事务数量更多的建议事务数量,而在执行时长超时则选择比第一提案事务数量更少的建议事务数量。然后,再基于所选择的建议事务数量进行确定第二共识轮次的事务数量限额,例如可以是均值、最大值、中位数或者选择其中一个作为结果等。
步骤S530,按照事务数量限额,将本地事务池中的区块链事务打包,生成供区块链中第二共识轮次内多个区块链节点投票的第二区块提案。
本地事务池(Local transaction pool)是区块链节点本地存储区块链事务的一个集合,主节点会从该池中获取事务进行打包生成区块提案。
在本实施例中,本地节点在下一轮的共识轮次中成为主节点。本地节点成为主节点后,会根据上一轮的投票结果来确定是否按照第一区块提案将事务打包上链。但无论第一区块提案是否达成共识。主节点在下一轮共识中,在需要进行提案时,会将上一轮共识中确定的第二共识轮次的事务数量限额作为提案时的事务数量限制。即,本地节点会将本地事务池中事务数量限额的区块链事务打包,生成供区块链中第二共识轮次内多个区块链节点投票的第二区块提案;及在区块链中广播第二区块提案。取决于第一区块提案共识的结果成功与否,第二区块提案中所包含的具体事务可以与第一区块提案相同或者不同。具体地,本地节点在打包第二区块提案时,会执行要打包的事务并且统计执行时长。本地节点会确保第二区块提案中的事务数量小于或者等于事务数量限额,并且第二区块提案中所有事务的总执行时长不超过区块链中的预设执行时长阈值。
总执行时长(Total execution time):区块链节点执行区块提案中所有区块链事务所花费的总时间,节点会根据该时长和事务完成数量生成事务建议数量。事务建议数量(Suggested quantity of transactions)与建议事务数量含义相同,是指节点根据执行区块提案中所有事务的总执行时长和完成事务数量生成的一个数量值,该数量值表示节点根据其对区块提案执行情况对下一轮共识提案中所要包含的事务数量提出的建议,会附加在投票结果中。
步骤S540,在区块链中广播第二区块提案。
第二区块提案(Second block proposal)是主节点在下一轮共识(第二共识轮次)中,按照第二共识轮次的事务数量限额,将本地事务池中的区块链事务打包生成的区块提案,用于指示区块链中第二共识轮次内多个区块链节点进行投票。
在打包完成后,本地节点作为当前共识轮次(第一区块提案完成后成为了上一轮共识)的主节点,会在区块链中广播第二区块提案。区块链中的从节点则会根据第二区块提案进行共识过程,并且在达成共识后在区块链中生成第二区块提案所提交的区块。可以理解的是,在第二区块提案的共识过程中,各个从节点也会基于第二区块提案的事务数量和执行时长进行事务数量的建议,从而继续对再下一轮共识轮次的区块提案中打包的事务数量进行调整。因此,区块提案中的事务数量限制会随着共识过程中各个从节点所提出建议事务数量而进行动态的调整。这能够运行过程中及时解决事务过多而导致超时或者事务过少而浪费资源的问题,而不需要人工进行干预和配置,使得区块链的运行效率更高。
在本申请的实施例中,区块链节点在获取到针对第一区块提案的第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果后,会根据各个投票结果中的建议事务数量来生成第二共识轮次的事务数量限额,第二共识轮次是第一共识轮次的下一共识轮次,并且在成为提案节点的时候,按照所确定的第二共识轮次的事务数量限额来打包区块链事务成为新的区块提案,并在区块链中广播,以根据在区块链中生成新区块。通过这样的方式,在进行共识的过程中根据各个节点的建议来调整下一次进行提案时打包的事务数量,从而能够在提案的执行结果和执行时长过程时自动对区块提案中所包含的事务进行调整,避免区块提案中事务过多而造成在验证提案时执行超时,进而防止验证提案执行超时而造成提案失败,有利于提高区块链的运行效率。
在本申请的实施例中,还提出了对图5所示实施例的技术方案进行细化的其它实施例,具体如图6所示,在本申请的一个实施例的区块提案方法中,可以包括如下步骤:
步骤S610,获取区块链中第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果,每个投票结果包含建议事务数量,建议事务数量根据第一区块提案中的第一提案事务数量、及产生投票结果的区块链节点执行第一区块提案的执行时长确定。
可选地,步骤S610的实现细节与图5中所示的步骤S510一致,不再赘述。
步骤S620,根据第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果,确定针对第一区块提案的提案共识结果;
提案共识结果(Proposal consensus result)是指根据区块链的共识策略,对第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果进行判断后,得出的关于第一区块提案是否达成共识的结果,通常分为提案成功和提案失败。
步骤S630,根据提案共识结果,从第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中获取与提案共识结果相对应的投票结果,作为候选投票结果;
候选投票结果(Candidate voting result)是指根据提案共识结果,从第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中获取的与提案共识结果相对应的投票结果,用于生成第二共识轮次的事务数量限额。
步骤S640,根据候选投票结果中的建议事务数量,生成第二共识轮次的事务数量限额,第二共识轮次是第一共识轮次的下一共识轮次。
在本实施例中,本地节点在生成第二共识轮次的事务数量限额时,会根据提案共识结果来从第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中获取与提案共识结果相对应的投票结果。具体地,本地节点会先根据第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果,确定针对第一区块提案的提案共识结果。确定过程通常会根据区块链的共识策略来确定。
例如,在3f+1的共识网络中,对于每轮投票,每个节点都只需要收集2f+1张投票结果即可确定共识成功,或者收集到f+1张投票结果就可以确定共识失败,但每个节点收集到的投票结果可能是不同的。共识网络(Consensus network):由多个区块链节点组成的网络,节点在该网络中针对区块提案进行投票和达成共识的过程。不同的共识网络有不同的共识策略,例如在3f+1的共识网络中,对于每轮投票,每个节点都只需要收集2f+1张投票结果即可确定共识成功,或者收集到f+1张投票结果就可以确定共识失败。
本地节点在确定提案共识结果后,会从第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中获取与提案共识结果相对应的投票结果,作为候选投票结果。具体地,第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果对于提案共识结果的影响程度和作用是不同的,而本地节点则基于各个投票结果对于提案共识结果的影响程度、关联程度和作用来选择投票结果。通常,本地节点会选择对提案共识结果起到正向作用的投票结果作为候选投票结果。投票结果的作用总体分为正向作用、负向作用和无作用,正向作用标识其与共识结果的方向一致,负向作用则是与共识结果的方向相反,无作用则是与共识结果没有关联。针对共识结果是失败的情况,则反对票是正向作用,赞成票是负向作用,而弃权票则是无作用。例如,共识结果是失败,但失败原因是某一个共识节点启动了一票否决的机制,则该否决票对共识结果的影响和作用是最大的,则获取该投票结果,作为候选投票结果。在一些实施例中,本地节点会按照预设的比例,从正向作用的投票结果和负向作用的投票结果中分别选择一部分来作为候选投票结果。最后,本地节点会根据候选投票结果中的建议事务数量,生成第二共识轮次的事务数量限额,第二共识轮次是第一共识轮次的下一共识轮次。通过根据与提案共识结果相对应的投票结果中的建议事务数量,生成第二共识轮次的事务数量限额,第二共识轮次是第一共识轮次的下一共识轮次,从而能够使得第二共识轮次的事务数量限额的确定因素中投票正确的结果的影响程度更高,有利于提高所确定的第二共识轮次的事务数量限额的准确性。
步骤S650,按照事务数量限额,将本地事务池中的区块链事务打包,生成供区块链中第二共识轮次内多个区块链节点投票的第二区块提案。
可选地,步骤S650的实现细节与图5中所示的步骤S530一致,不再赘述。
步骤S660,在区块链中广播第二区块提案。
可选地,步骤S660的实现细节与图5中所示的步骤S540一致,不再赘述。
在本申请的实施例中,区块链节点在获取到针对第一区块提案的第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果后,会根据各个投票结果中的建议事务数量来生成第二共识轮次的事务数量限额,并且在成为提案节点的时候,按照所确定的第二共识轮次的事务数量限额来打包区块链事务成为新的区块提案,并在区块链中广播,以根据在区块链中生成新区块。通过这样的方式,在进行共识的过程中根据各个节点的建议来调整下一次进行提案时打包的事务数量,从而能够在提案的执行结果和执行时长过程时自动对区块提案中所包含的事务进行调整,避免区块提案中事务过多而造成在验证提案时执行超时,进而防止验证提案执行超时而造成提案失败,有利于提高区块链的运行效率。
在本申请一些可选的实施例中,基于上述的技术方案,在根据提案共识结果,从第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中获取与提案共识结果相对应的投票结果,作为候选投票结果过程中,如果提案共识结果为提案成功,则节点从第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中投赞成票的投票结果,作为候选投票结果。如果提案共识结果为提案失败,则节点从第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中投反对票的投票结果,作为候选投票结果。在本实施例中,本地节点会选择投票内容符合提案共识结果的投票结果作为候选投票结果,从而能够避免对共识节点判断错误的节点所提出的建议数量影响所确定的指定数量,有利于降低确定事务数量的过程受到作恶数据影响的概率,提高区块链系统的安全性。
在本申请一些可选的实施例中,基于上述的技术方案,在根据候选投票结果中的建议事务数量,生成第二共识轮次的事务数量限额的过程中,如果提案共识结果为提案成功,则获取第一区块提案中的第一提案事务数量。如果第一提案事务数量大于或等于候选投票结果中的建议事务数量,则节点将第一提案事务数量作为第二共识轮次的事务数量限额。如果第一提案事务数量小于候选投票结果中的建议事务数量,则节点根据第一提案事务数量与所选择的建议事务数量的均值,生成第二共识轮次的事务数量限额。
具体地,在共识结果为提案共识成功时,存在两种情况,即从节点对主节点在第一区块提案中打包的第一提案事务数量认可或者不认可。具体地,如果第一提案事务数量大于或等于候选投票结果中的建议事务数量,则表示从节点对主节点打包的数量认可,可以直接第一提案事务数量作为第二共识轮次的事务数量限额。请参阅图7,图7为本申请实施例中生成第二共识轮次的事务数量限额的逻辑示意图。如图7所示,节点2提出的建议事务数量与主节点打包的数量是一致的,因此如果节点2在下一轮成为主节点,则直接将主节点打包的数量作为下一轮共识中的打包数量。需要注意的是,节点4由于投了反对票,因此其所提供的建议事务数量不用考虑,如果节点4在下一轮成为主节点,也会直接将主节点打包的数量(即10000笔)作为下一轮共识中的打包数量。如果第一提案事务数量小于候选投票结果中的建议事务数量,则表示从节点对主节点打包的事务数量不认可,节点可以根据第一提案事务数量与所选择的建议事务数量的均值,生成第二共识轮次的事务数量限额。请参阅图8,图8为本申请实施例中生成第二共识轮次的事务数量限额的另一逻辑示意图。如图8所示,节点2提出的建议事务数量为10000笔,而主节点只打包了5000笔,此时,节点2对主节点的打包数量不认可,则节点2在成为主节点时,会根据二者数量的均值来确定第二共识轮次的事务数量限额,即7500笔。节点4也是类似,其所提出的建议事务数量为6000笔,也高于主节点的打包数量,因此,在节点4成为主节点时,在提案中打包事务数量会是7000笔。在此需要注意的是,节点2与节点4所接收到的投票结果不同,由于节点2没有接收到节点4的投票结果,因此,在节点2确定第二共识轮次的事务数量限额时,只考虑节点1和节点2所提出的数量,而节点3则由于数量超限而本舍弃。在本实施例中,根据从节点的建议事务数量与主节点所打包的事务数量的比对结果来对应确定第二共识轮次的事务数量限额,从而能够对于主节点打包数量较少时及时提高区块提案的事务数量限制,从而避免区块中事务数量过少而导致共识过程中的处理资源浪费,有利于提高方案的资源利用率。
在本申请一些可选的实施例中,基于上述的技术方案,候选投票结果包含第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果。在如果第一提案事务数量小于候选投票结果中的建议事务数量,则根据第一提案事务数量与所选择的建议事务数量的均值,生成第二共识轮次的事务数量限额的过程中,如果第一提案事务数量小于候选投票结果中的建议事务数量,则节点获取区块链的区块事务数量阈值。如果候选投票结果中任一投票结果的建议事务数量大于区块事务数量阈值,则将投票结果从候选投票结果中删除。然后,节点根据第一提案事务数量与候选投票结果中各个投票结果的建议事务数量的均值,生成第二共识轮次的事务数量限额。在本申请方案中,如果从节点所确定的建议事务数量高于区块链配置的最大数量限制,则会将该建议事务数量舍弃,从而能够避免区块提案中事务数量过多导致提案执行超时而引起共识失败,有利于提高方案的稳定性。区块事务数量阈值(Block transaction quantity threshold)是区块链配置的一个最大数量限制,用于限制区块提案中事务的数量,若从节点所确定的建议事务数量高于该阈值,则该建议事务数量会被舍弃。
在本申请一些可选的实施例中,基于上述的技术方案,在根据候选投票结果中的建议事务数量,生成第二共识轮次的事务数量限额的过程中,如果提案共识结果为提案失败,则节点获取候选投票结果中的建议事务数量,然后根据候选投票结果中建议事务数量的总和以及候选投票结果的数量,确定第二共识轮次的事务数量限额。在本实施例中,如果提案共识失败,则只会选择投反对票的投票结果中的建议事务数量来确定第二共识轮次的事务数量限额。
请参阅图9,图9为本申请实施例中生成第二共识轮次的事务数量限额的另一逻辑示意图。如图9所示,由于共识结果失败,本地节点只会选择包含反对票的节点3和节点4的投票结果作为候选投票结果,而所确定的第二共识轮次的事务数量限额也是二者建议数量的均值。第二共识轮次的事务数量限额可以按照其他的方式确定,例如最大值或者最小值,或者先基于建议事务数量进行聚类后再进行分类计算等。通过在提案失败时是只按照失败的候选投票结果中的建议事务数量来确定第二共识轮次的事务数量限额,能够对过高的事务数量或者过长的执行时间进行及时的缩减,有利于避免后续共识过程再次失败,提高共识成功率。
聚类(Clustering):在确定第二共识轮次的事务数量限额时,如果提案共识失败,可先基于建议事务数量将数据进行分组,使得同一组内的数据具有较高的相似性,不同组的数据具有较大的差异性,然后再对不同组进行分类计算以确定限额的一种数据处理方法。
在本申请的实施例中,还提出了对图5所示实施例的技术方案进行细化的其它实施例,具体如图10所示,在本申请的一个实施例的区块提案方法中,可以包括如下步骤:
步骤S1010,获取区块链中第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果,每个投票结果包含建议事务数量,建议事务数量根据第一区块提案中的第一提案事务数量、及产生投票结果的区块链节点执行第一区块提案的执行时长确定。
可选地,步骤S1010的实现细节与图5中所示的步骤S510一致,不再赘述。
步骤S1020,根据多个投票结果各自包含的建议事务数量,生成第二共识轮次的事务数量限额,第二共识轮次是第一共识轮次的下一共识轮次。
可选地,步骤S1020的实现细节与图5中所示的步骤S520一致,不再赘述。
步骤S1030,按照事务数量限额,将本地事务池中的区块链事务打包,生成供区块链中第二共识轮次内多个区块链节点投票的第二区块提案。
可选地,步骤S1030的实现细节与图5中所示的步骤S530一致,不再赘述。
步骤S1040,在区块链中广播第二区块提案。
可选地,步骤S1040的实现细节与图5中所示的步骤S540一致,不再赘述。
步骤S1050,获取主节点生成的第三区块提案;
第三区块提案(Third block proposal)是在第二区块提案之后,由主节点打包生成的区块提案,但不一定是第二区块提案的下一轮提案。
步骤S1060,执行第三区块提案中的区块链事务,得到第三区块提案的执行结果和执行时长;
步骤S1070,根据执行结果和执行时长,确定本地节点的建议事务数量;
步骤S1080,根据第三区块提案的执行结果和本地节点的建议事务数量,生成针对第三区块提案的节点投票结果;
节点投票结果(Node voting result)是本地节点根据第三区块提案的执行结果和本地节点的建议事务数量生成的结果,包括投票信息、投票签名、建议事务数量、当前区块高度、共识轮数以及信息签名等内容,用于在区块链中广播,参与对第三区块提案的共识。
步骤S1090,在区块链中广播节点投票结果。
在本实施例中,本地节点在广播第二区块提案后,身份从主节点切换成从节点,而一个其他节点成为主节点。该主节点会打包生成第三区块提案。需要注意的是,第三区块提案是第二区块提案之后的提案,但不一定是第二区块提案的下一轮提案。本地节点作为从节点,会执行第三区块提案中的区块链事务,得到第三区块提案的执行结果和执行时长。随后,根据执行结果和执行时长,确定本地节点的建议事务数量。具体地,如果执行结果为成功,但执行时长较短,则可以在建议事务数量中提高事务数量,而如执行结果为失败或者执行时长较长,则可以在建议事务数量中降低事务数量。随后,本地节点根据第三区块提案的执行结果和本地节点的建议事务数量,生成针对第三区块提案的节点投票结果。请参阅图11,图11为本申请实施例中节点投票结果的示意图。如图11所示,节点投票结果总体分为两类,赞成票和反对票。这两种结果都有对应的标识,并且都会附带本地节点的建议事务数量。最后,本地节点在区块链中广播节点投票结果。当存在作恶节点时,由于区块中事务数量上限的限制,一般作恶节点会发送一些比较低的值,这样就会导致持续的几轮区块中的事务数据量都持续的下降,但可以达成共识,只是每个区块中的事务量比较少。通过在投赞成票时也增加建议事务数量,从而能够及时对过低的事务数量进行修正,从而避免作恶节点造成区块链事务处理效率下降,提高方案的安全性。
在本申请的实施例中,区块链节点在获取到针对第一区块提案的第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果后,会根据各个投票结果中的建议事务数量来生成第二共识轮次的事务数量限额,第二共识轮次是第一共识轮次的下一共识轮次,并且在成为提案节点的时候,按照所确定的第二共识轮次的事务数量限额来打包区块链事务成为新的区块提案,并在区块链中广播,以根据在区块链中生成新区块。通过这样的方式,在进行共识的过程中根据各个节点的建议来调整下一次进行提案时打包的事务数量,从而能够在提案的执行结果和执行时长过程时自动对区块提案中所包含的事务进行调整,避免区块提案中事务过多而造成在验证提案时执行超时,进而防止验证提案执行超时而造成提案失败,有利于提高区块链的运行效率。
在本申请一些可选的实施例中,基于上述的技术方案,在根据第三区块提案的执行结果和本地节点的建议事务数量,生成针对第三区块提案的节点投票结果的过程中,节点会根据第三区块提案中区块链事务的执行结果和第三区块提案中的提案结果之间的匹配结果,确定针对第三区块提案的投票信息。然后,节点根据本地节点的区块链密钥,对投票信息进行签名,得到投票签名,并且根据本地节点的区块链密钥,对建议事务数量进行签名,得到信息签名。最后,节点根据投票信息和投票签名以及建议事务数量和信息签名,生成针对第三区块提案的节点投票结果。
区块链密钥(Blockchain key)是区块链节点所拥有的一种密钥,用于对投票信息、建议事务数量等重要信息进行签名,以保证信息在传输和存储过程中的安全性、真实性和完整性,防止信息被篡改或伪造。
投票签名(Voting signature)是指本地节点根据自身的区块链密钥,对针对第三区块提案的投票信息进行签名后得到的结果,用于确保投票信息的真实性和完整性。投票信息(Voting information)是根据第三区块提案中区块链事务的执行结果和第三区块提案中的提案结果之间的匹配结果确定的信息,通常为赞成或者反对,用于表达节点对第三区块提案的态度,是节点投票结果的重要组成部分。
信息签名(Information signature)是本地节点根据自身的区块链密钥,对建议事务数量、区块链中的当前区块高度以及第三区块提案的共识轮数进行签名后得到的结果,用于防止投票结果的伪造发送,确保建议事务数量等信息的真实性和有效性。
当前区块高度(Current block height)是指区块链中当前所在区块的位置标识,代表从区块链的创始块开始到当前区块所经过的区块数量,在生成节点投票结果时添加该信息,可用于判断投票结果是否是针对当前共识轮次发出,防止投票结果的伪造发送。
在本实施例中,在节点投票结果中,分别对投票信息和建议事务数量级进行签名,从而使得对不具备提供建议事务数量能力的节点仍可以只基于投票信息和对应签名来进行共识,从而提高方案的兼容能力。
在本申请一些可选的实施例中,基于上述的技术方案,在根据本地节点的区块链密钥,对建议事务数量进行签名,得到信息签名的过程中,节点会获取区块链中的当前区块高度以及第三区块提案的共识轮数;根据本地节点的区块链密钥,对建议事务数量、当前区块高度和共识轮数进行签名,得到信息签名。在生成节点投票结果时,节点会根据投票信息和投票签名以及建议事务数量、当前区块高度和共识轮数和信息签名,生成针对第三区块提案的节点投票结果。共识轮数(Consensus round number)是指在区块链的共识过程中,针对不同区块提案进行投票和达成共识的轮次编号,用于标识当前处于哪一轮共识,在生成节点投票结果时添加该信息,有助于节点判断投票结果的时效性,避免受到伪造发送的投票结果的影响。
请参阅图12,图12为本申请实施例中节点投票结果具体结构的示意图。如图12所示,在本实施例中,在节点投票结果还进一步添加了当前区块高度和共识轮数,主要用于防止投票结果的伪造发送。具体地,作恶节点可能会收集其他节点在之前轮次的投票结果,然后在下一轮共识时将之前轮次中其他节点的投票结果发出,而造成其他节点将其误认为是原节点在当前轮次发出的结果而造成事务数量的确认错误。而节点投票结果中的当前区块高度和共识轮数可以供节点判断投票结果是否是针对当前共识轮次发出,从而避免受到伪造发送的投票结果的影响,提高方案的安全性。
在本申请一些可选的实施例中,基于上述的技术方案,在根据执行结果和执行时长,确定本地节点的建议事务数量的过程中,节点根据第一提案事务数量、节点能力参数和执行时长,确定本地节点的候选建议数量,其中,节点能力参数是根据本地节点的历史事务执行结果确定的。如果执行结果与第三区块提案中的提案结果相匹配,则节点将候选建议数量和第一提案事务数量中更大的数量作为本地节点的建议事务数量。如果执行结果与第三区块提案中的提案结果不匹配,则节点将候选建议数量和第一提案事务数量中更小的数量作为本地节点的建议事务数量。
节点能力参数(Node capability parameter)是根据本地节点的历史事务执行结果确定的一个参数,用于确定本地节点的候选建议数量,并可根据其他区块链节点的建议事务数量进行更新。候选建议数量(Candidate suggested quantity)是本地节点根据第一提案事务数量、节点能力参数和执行时长确定的一个数量值,用于确定本地节点的建议事务数量。
在本实施例中,本地节点根据历史事务所确定的节点能力参数来确定候选建议数量。具体地,候选建议数量可以是(当前数量*X)/当前时间,其中X是节点能力参数。节点能力参数是根据本地节点的历史事务执行结果确定的,例如,根据历史事务执行与当前数量和其他节点提议的数量之间的差值确定。在确定本地节点的候选建议数量后,如果执行结果与第三区块提案中的提案结果相匹配,则选择候选建议数量和第一提案事务数量中更大的数量作为建议事务数量,反之,如果执行结果与第三区块提案中的提案结果不匹配,则选择二者中更小的作为建议事务数量。本实施例中,根据历史事务执行结果确定的节点能力参数来确定候选建议数量,再根据执行结果与提案结果的匹配情况来选择建议事务数量,相较于直接根据本地节点的计算能力来确定建议事务数量,能够使得所确定的建议事务数量与执行结果的匹配程度更高,有利于所确定的建议事务数量的准确性。
在本申请一些可选的实施例中,基于上述的技术方案,节点还会根据第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中其他区块链节点的建议事务数量,确定基线数量,然后根据基线数量、第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中本地节点的建议事务数量以及区块链中提案执行时间阈值,更新本地节点的节点能力参数。
基线数量(Baseline quantity)是根据第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中其他区块链节点的建议事务数量确定的一个数量值,用于更新本地节点的节点能力参数。提案执行时间阈值(Proposal execution time threshold)是区块链中预设的一个时间限制,用于限制区块提案中所有事务的总执行时长,若执行时长超过该阈值,可能会导致提案失败。
在本实施例中,区块链节点会根据其他节点所提出的建议事务数量,来调整本地节点的节点能力参数。具体地,本地节点会根据第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中其他区块链节点的建议事务数量,确定基线数量。例如,对于基于相同数量(例如10000)的事务,其他节点的建议事务数量都是5000,而本节点的建议事务数量是4000的话,则可以将5000作为基线数量。可以理解,基线处理可以是其他区块链节点的建议事务数量中出现次数最多的数量,但也可以根据其他方式确定,例如均值或者中位值等。随后,本地节点会根据基线数量调整自己的节点能力参数。例如,本地节点可以根据基线数量与建议事务数量之间的差值和提案执行时间阈值之间的比率来扩大当前的节点能力参数。具体地,在一个实施例中,节点能力参数可以=4000*10*0.8/5000,其中,10为提案执行时间阈值,即10秒,而0.8则是预设的调整阈值。可以理解的是,更新本地节点的节点能力参数的过程通常在共识完成之后进行。在本实施例中,本地节点会根据其他节点的建议事务数量来更新本地节点的节点能力参数,从而能够对本地节点生成的建议事务数量进行及时调整,避免建议事务数量过高或者过低而影响区块中打包的事务数量,提高区块中事务数量的合理性。
下面结合具体实施例介绍本申请技术方案的具体实施流程。请参阅13,图13为本申请实施例中区块提案处理整体流程的示意性流程图。如图13所示,当前的共识节点会从事务池中获取要打包的事务,执行所获取的事务,从而生成本轮共识的区块提案。随后当前主节点将提案广播到区块链中的其他节点。其他节点主要分为普通节点和下一轮主节点,但这两种节点在当前轮次的共识过程中的处理过程相同。以普通节点为例,其会解析广播的网络信息,从而获取到广播的区块提案。网络信息(Network information):在区块链网络中,节点之间进行通信时所传输的信息,包括区块提案、投票结果等数据,普通节点可以通过解析广播的网络信息来获取广播的区块提案等内容。
随后,节点对提案对象本身进行校验。如果校验不通过,则直接生成反对票。如果校验通过,则节点会执行提案中的所有事务,并记录事务完成数量。随后,根据总执行时长和完成事务数量生成事务建议数量。节点会校验事务执行结果与提案结果,如果校验通过,则生成赞成票,不通过则生成反对票。此时,这两种票都会附加建议事务数量。随后,节点将投票结果广播给区块链中的其他节点。区块链中的各个节点都会根据投票中的建议事务数量,计算下次打包事务时的最大数量。在本轮共识完成后,下一轮主节点会按照上一轮确定的数量,从事务池中获取要打包的事务,执行所获取的事务,从而生成下一轮共识的区块提案。
提案对象(Proposal object):即区块提案,是主节点将区块链事务打包生成的对象,用于在区块链节点之间进行共识,普通节点会对提案对象本身进行校验,以判断其是否符合要求。
普通节点(Ordinary node):在区块链的共识过程中,除主节点和下一轮主节点之外的节点,其在当前轮次的共识过程中,会接收主节点广播的区块提案,对提案进行校验和执行,根据执行结果生成投票结果并广播,同时根据总执行时长和完成事务数量生成事务建议数量。
事务完成数量(Number of completed transactions):节点在执行区块提案中的区块链事务时,成功完成的事务的数量,节点会根据该数量和总执行时长生成事务建议数量。
应当注意,尽管在附图中以特定顺序描述了本申请中方法的各个步骤,但是,这并非要求或者暗示必须按照该特定顺序来执行这些步骤,或是必须执行全部所示的步骤才能实现期望的结果。附加的或备选的,可以省略某些步骤,将多个步骤合并为一个步骤执行,以及/或者将一个步骤分解为多个步骤执行等。
以下介绍本申请的装置实施,可以用于执行本申请上述实施例中的区块提案方法。图14示意性地示出了本申请实施例中区块提案装置的组成框图。如图14所示,区块提案装置1400主要可以包括:
获取模块1410,配置成获取区块链中第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果,每个投票结果包含建议事务数量,建议事务数量根据第一区块提案中的第一提案事务数量、及产生投票结果的区块链节点执行第一区块提案的执行时长确定;
生成模块1420,配置成根据多个投票结果各自包含的建议事务数量,生成第二共识轮次的事务数量限额,第二共识轮次是第一共识轮次的下一共识轮次;
打包模块1430,配置成按照事务数量限额,将本地事务池中的区块链事务打包,生成供区块链中第二共识轮次内多个区块链节点投票的第二区块提案;
广播模块1440,配置成在区块链中广播第二区块提案。
在本申请的一些实施例中,基于以上技术方案,生成模块1420具体配置成:根据第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果,确定针对第一区块提案的提案共识结果;根据提案共识结果,从第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中获取与提案共识结果相对应的投票结果,作为候选投票结果;根据候选投票结果中的建议事务数量,生成第二共识轮次的事务数量限额,第二共识轮次是第一共识轮次的下一共识轮次。
在本申请的一些实施例中,基于以上技术方案,生成模块1420具体配置成:若提案共识结果为提案成功,则从第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中投赞成票的投票结果,作为候选投票结果;若提案共识结果为提案失败,则从第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中投反对票的投票结果,作为候选投票结果。
在本申请的一些实施例中,基于以上技术方案,生成模块1420具体配置成:若提案共识结果为提案成功,则获取第一区块提案中的第一提案事务数量;若第一提案事务数量大于或等于候选投票结果中的建议事务数量,则将第一提案事务数量作为第二共识轮次的事务数量限额;若第一提案事务数量小于候选投票结果中的建议事务数量,则根据第一提案事务数量与所选择的建议事务数量的均值,生成第二共识轮次的事务数量限额。
在本申请的一些实施例中,基于以上技术方案,候选投票结果包含第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果;生成模块1420具体配置成:若第一提案事务数量小于候选投票结果中的建议事务数量,则获取区块链的区块事务数量阈值;若候选投票结果中任一投票结果的建议事务数量大于区块事务数量阈值,则将投票结果从候选投票结果中删除;根据第一提案事务数量与候选投票结果中各个投票结果的建议事务数量的均值,生成第二共识轮次的事务数量限额。
在本申请的一些实施例中,基于以上技术方案,生成模块1420具体配置成:若提案共识结果为提案失败,则获取候选投票结果中的建议事务数量;根据候选投票结果中建议事务数量的总和以及候选投票结果的数量,确定第二共识轮次的事务数量限额。
在本申请的一些实施例中,基于以上技术方案,广播模块1440还配置成:获取主节点生成的第三区块提案;执行第三区块提案中的区块链事务,得到第三区块提案的执行结果和执行时长;根据执行结果和执行时长,确定本地节点的建议事务数量;根据第三区块提案的执行结果和本地节点的建议事务数量,生成针对第三区块提案的节点投票结果;在区块链中广播节点投票结果。
在本申请的一些实施例中,基于以上技术方案,广播模块1440具体配置成:根据第三区块提案中区块链事务的执行结果和第三区块提案中的提案结果之间的匹配结果,确定针对第三区块提案的投票信息;根据本地节点的区块链密钥,对投票信息进行签名,得到投票签名;根据本地节点的区块链密钥,对建议事务数量进行签名,得到信息签名;根据投票信息和投票签名以及建议事务数量和信息签名,生成针对第三区块提案的节点投票结果。
在本申请的一些实施例中,基于以上技术方案,广播模块1440具体配置成:获取区块链中的当前区块高度以及第三区块提案的共识轮数;根据本地节点的区块链密钥,对建议事务数量、当前区块高度和共识轮数进行签名,得到信息签名;根据投票信息和投票签名以及建议事务数量、当前区块高度和共识轮数和信息签名,生成针对第三区块提案的节点投票结果。
在本申请的一些实施例中,基于以上技术方案,广播模块1440具体配置成:根据第一提案事务数量、节点能力参数和执行时长,确定本地节点的候选建议数量,其中,节点能力参数是根据本地节点的历史事务执行结果确定的;若执行结果与第三区块提案中的提案结果相匹配,则将候选建议数量和第一提案事务数量中更大的数量作为本地节点的建议事务数量;若执行结果与第三区块提案中的提案结果不匹配,则将候选建议数量和第一提案事务数量中更小的数量作为本地节点的建议事务数量。
在本申请的一些实施例中,基于以上技术方案,广播模块1440具体配置成:根据第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中其他区块链节点的建议事务数量,确定基线数量;根据基线数量、第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中本地节点的建议事务数量以及区块链中提案执行时间阈值,更新本地节点的节点能力参数。
需要说明的是,上述实施例所提供的装置与上述实施例所提供的方法属于同一构思,其中各个模块执行操作的具体方式已经在方法实施例中进行了详细描述,此处不再赘述。
本申请提供的区块提案方法、装置、电子设备、计算机可读介质和计算机程序产品,区块链中的区块链节点获取区块链中第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果,每个投票结果包含建议事务数量,该建议事务数量依据第一区块提案中的第一提案事务数量、及产生投票结果的区块链节点执行第一区块提案的执行时长确定。然后,根据多个投票结果各自包含的建议事务数量,生成第二共识轮次的事务数量限额,第二共识轮次是第一共识轮次的下一共识轮次。接着,按照事务数量限额,将本地事务池中的区块链事务打包,生成第二区块提案。最后,在区块链中广播第二区块提案,第二区块提案用于指示区块链中第二共识轮次内多个区块链节点进行投票。通过这种方式,能在共识过程中依据各节点建议调整下一次提案时打包的事务数量,自动对区块提案所包含事务进行调整,避免事务过多导致验证提案时执行超时,防止提案失败,提高区块链运行效率。
进一步地,区块链节点根据第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果,确定针对第一区块提案的提案共识结果,再根据提案共识结果,从第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中获取与提案共识结果相对应的投票结果,作为候选投票结果,进而根据候选投票结果中的建议事务数量,生成第二共识轮次的事务数量限额。这样做可使第二共识轮次事务数量限额的确定因素中,投票正确结果的影响程度更高,提高所确定事务数量限额的准确性。
当提案共识结果为提案成功时,区块链节点从第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中投赞成票的投票结果,作为候选投票结果;当提案共识结果为提案失败时,从第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中投反对票的投票结果,作为候选投票结果。这能避免对共识节点判断错误的节点所提建议数量影响指定数量,降低确定事务数量过程受作恶数据影响的概率,提高区块链系统安全性。
若提案共识结果为提案成功,区块链节点获取第一区块提案中的第一提案事务数量,若第一提案事务数量大于或等于候选投票结果中的建议事务数量,则将第一提案事务数量作为第二共识轮次的事务数量限额。如此可在从节点认可主节点打包数量时,直接沿用第一提案事务数量作为下一轮事务数量限额。
若第一提案事务数量小于候选投票结果中的建议事务数量,区块链节点根据第一提案事务数量与所选择的建议事务数量的均值,生成第二共识轮次的事务数量限额。这能在主节点打包数量较少时,及时提高区块提案的事务数量限制,避免区块中事务数量过少导致共识过程处理资源浪费,提高方案资源利用率。
候选投票结果包含第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果,若第一提案事务数量小于候选投票结果中的建议事务数量,区块链节点获取区块链的区块事务数量阈值,若候选投票结果中任一投票结果的建议事务数量大于区块事务数量阈值,则将该投票结果从候选投票结果中删除,再根据第一提案事务数量与候选投票结果中各个投票结果的建议事务数量的均值,生成第二共识轮次的事务数量限额。这样能避免区块提案中事务数量过多导致提案执行超时而引起共识失败,提高方案稳定性。
若提案共识结果为提案失败,区块链节点获取候选投票结果中的建议事务数量,根据候选投票结果中建议事务数量的总和以及候选投票结果的数量,确定第二共识轮次的事务数量限额。这可在提案失败时,通过只按失败的候选投票结果中的建议事务数量确定限额,及时缩减过高事务数量或过长执行时间,避免后续共识过程再次失败,提高共识成功率。
在区块链中广播第二区块提案之后,区块链节点获取主节点生成的第三区块提案,执行第三区块提案中的区块链事务,得到第三区块提案的执行结果和执行时长,根据执行结果和执行时长,确定本地节点的建议事务数量,根据第三区块提案的执行结果和本地节点的建议事务数量,生成针对第三区块提案的节点投票结果,在区块链中广播节点投票结果。通过在投赞成票时也增加建议事务数量,可及时修正过低事务数量,避免作恶节点造成区块链事务处理效率下降,提高方案安全性。
区块链节点根据第三区块提案中区块链事务的执行结果和第三区块提案中的提案结果之间的匹配结果,确定针对第三区块提案的投票信息,根据本地节点的区块链密钥,对投票信息进行签名,得到投票签名,根据本地节点的区块链密钥,对建议事务数量进行签名,得到信息签名,根据投票信息和投票签名以及建议事务数量和信息签名,生成针对第三区块提案的节点投票结果。在节点投票结果中分别对投票信息和建议事务数量进行签名,可使不具备提供建议事务数量能力的节点仍能基于投票信息和对应签名进行共识,提高方案兼容能力。
区块链节点获取区块链中的当前区块高度以及第三区块提案的共识轮数,根据本地节点的区块链密钥,对建议事务数量、当前区块高度和共识轮数进行签名,得到信息签名,根据投票信息和投票签名以及建议事务数量、当前区块高度和共识轮数和信息签名,生成针对第三区块提案的节点投票结果。在节点投票结果中添加当前区块高度和共识轮数,可防止投票结果被伪造发送,避免节点受伪造投票结果影响而造成事务数量确认错误,提高方案安全性。
区块链节点根据第一提案事务数量、节点能力参数和执行时长,确定本地节点的候选建议数量,其中,节点能力参数根据本地节点的历史事务执行结果确定,若执行结果与第三区块提案中的提案结果相匹配,则将候选建议数量和第一提案事务数量中更大的数量作为本地节点的建议事务数量。相较于直接根据本地节点计算能力确定建议事务数量,这样能使确定的建议事务数量与执行结果匹配程度更高,提高建议事务数量的准确性。
若执行结果与第三区块提案中的提案结果不匹配,区块链节点将候选建议数量和第一提案事务数量中更小的数量作为本地节点的建议事务数量。这进一步完善了根据执行结果确定建议事务数量的方式,使建议事务数量更贴合实际执行情况。
区块链节点根据第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中其他区块链节点的建议事务数量,确定基线数量,根据基线数量、第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中本地节点的建议事务数量以及区块链中提案执行时间阈值,更新本地节点的节点能力参数。通过根据其他节点建议事务数量更新本地节点的节点能力参数,可及时调整本地节点生成的建议事务数量,避免建议事务数量过高或过低影响区块中打包的事务数量,提高区块中事务数量的合理性。
图15示出了适于用来实现本申请实施例的电子设备的计算机系统的结构示意图。
需要说明的是,图15示出的电子设备的计算机系统1500仅是一个示例,不应对本申请实施例的功能和使用范围带来任何限制。
如图15所示,计算机系统1500包括中央处理单元(Central Processing Unit,CPU)1501,其可以根据存储在只读存储器(Read-Only Memory,ROM)1502中的程序或者从储存部分1508加载到随机访问存储器(Random Access Memory,RAM)1503中的程序而执行各种适当的动作和处理。在RAM 1503中,还存储有系统操作所需的各种程序和数据。CPU 1501、ROM 1502以及RAM 1503通过总线1504彼此相连。输入/输出(Input/Output,I/O)接口1505也连接至总线1504。
以下部件连接至I/O接口1505:包括键盘、鼠标等的输入部分1506;包括诸如阴极射线管(Cathode Ray Tube,CRT)、液晶显示器(Liquid Crystal Display,LCD)等以及扬声器等的输出部分1507;包括硬盘等的储存部分1508;以及包括诸如LAN(Local Area Network,局域网)卡、调制解调器等的网络接口卡的通信部分1509。通信部分1509经由诸如因特网的网络执行通信处理。驱动器1510也根据需要连接至I/O接口1505。可拆卸介质1511,诸如磁盘、光盘、磁光盘、半导体存储器等等,根据需要安装在驱动器1510上,以便于从其上读出的计算机程序根据需要被安装入储存部分1508。
特别地,根据本申请的实施例,各个方法流程图中所描述的过程可以被实现为计算机软件程序。例如,本申请的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信部分1509从网络上被下载和安装,和/或从可拆卸介质1511被安装。在该计算机程序被中央处理单元(CPU)1501执行时,执行本申请的系统中限定的各种功能。
需要说明的是,本申请实施例所示的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(Erasable Programmable Read Only Memory,EPROM)、闪存、光纤、便携式紧凑磁盘只读存储器(Compact Disc Read-Only Memory,CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本申请中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本申请中,计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:无线、有线等等,或者上述的任意合适的组合。
附图中的流程图和框图,图示了按照本申请各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,上述模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图或流程图中的每个方框、以及框图或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。
应当注意,尽管在上文详细描述中提及了用于动作执行的设备的若干模块或者单元,但是这种划分并非强制性的。实际上,根据本申请的实施方式,上文描述的两个或更多模块或者单元的特征和功能可以在一个模块或者单元中具体化。反之,上文描述的一个模块或者单元的特征和功能可以进一步划分为由多个模块或者单元来具体化。
通过以上的实施方式的描述,本领域的技术人员易于理解,这里描述的示例实施方式可以通过软件实现,也可以通过软件结合必要的硬件的方式来实现。因此,根据本申请实施方式的技术方案可以以软件产品的形式体现出来,该软件产品可以存储在一个非易失性存储介质(可以是CD-ROM,U盘,移动硬盘等)中或网络上,包括若干指令以使得一台计算设备(可以是个人计算机、服务器、触控终端、或者网络设备等)执行根据本申请实施方式的方法。
本领域技术人员在考虑说明书及实践这里公开的发明后,将容易想到本申请的其它实施方案。本申请旨在涵盖本申请的任何变型、用途或者适应性变化,这些变型、用途或者适应性变化遵循本申请的一般性原理并包括本申请未公开的本技术领域中的公知常识或惯用技术手段。
以上实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。
以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。

Claims (17)

  1. 一种区块提案方法,由区块链中的区块链节点执行,包括:
    获取区块链中第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果,每个投票结果包含建议事务数量,所述建议事务数量根据所述第一区块提案中的第一提案事务数量、及产生所述投票结果的区块链节点执行所述第一区块提案的执行时长确定;
    根据所述多个投票结果各自包含的建议事务数量,生成第二共识轮次的事务数量限额,所述第二共识轮次是所述第一共识轮次的下一共识轮次;
    按照所述事务数量限额,将本地事务池中的区块链事务打包,生成供所述区块链中第二共识轮次内多个区块链节点投票的第二区块提案;及
    在所述区块链中广播所述第二区块提案。
  2. 根据权利要求1所述的区块提案方法,所述根据所述多个投票结果各自包含的建议事务数量,生成第二共识轮次的事务数量限额,包括:
    根据所述第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果,确定针对所述第一区块提案的提案共识结果;
    根据所述提案共识结果,从所述第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中获取与所述提案共识结果相对应的投票结果,作为候选投票结果;
    根据所述候选投票结果中的建议事务数量,生成第二共识轮次的事务数量限额。
  3. 根据权利要求2所述的区块提案方法,所述根据所述提案共识结果,从所述第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中获取与所述提案共识结果相对应的投票结果,作为候选投票结果,包括:
    若所述提案共识结果为提案成功,则从所述第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中投赞成票的投票结果,作为候选投票结果;
    若所述提案共识结果为提案失败,则从所述第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中投反对票的投票结果,作为候选投票结果。
  4. 根据权利要求2所述的区块提案方法,所述根据所述候选投票结果中的建议事务数量,生成第二共识轮次的事务数量限额,包括:
    若所述提案共识结果为提案成功,则获取所述第一区块提案中的第一提案事务数量;
    若所述第一提案事务数量大于或等于所述候选投票结果中的建议事务数量,则将所述第一提案事务数量作为第二共识轮次的事务数量限额。
  5. 根据权利要求4所述的区块提案方法,所述根据所述候选投票结果中的建议事务数量,生成第二共识轮次的事务数量限额还包括:
    若所述第一提案事务数量小于所述候选投票结果中的建议事务数量,则根据所述第一提案事务数量与所选择的建议事务数量的均值,生成第二共识轮次的事务数量限额。
  6. 根据权利要求5所述的区块提案方法,所述候选投票结果包含第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果;所述若所述第一提案事务数量小于所述候选投票结果中的建议事务数量,则根据所述第一提案事务数量与所选择的建议事务数量的均值,生成第二共识轮次的事务数量限额,包括:
    若所述第一提案事务数量小于所述候选投票结果中的建议事务数量,则获取所述区块链的区块事务数量阈值;
    若所述候选投票结果中任一投票结果的建议事务数量大于所述区块事务数量阈值,则将所述投票结果从所述候选投票结果中删除;
    根据所述第一提案事务数量与所述候选投票结果中各个投票结果的建议事务数量的均值,生成第二共识轮次的事务数量限额。
  7. 根据权利要求2至6任一项所述的区块提案方法,所述根据所述候选投票结果中的建议事务数量,生成第二共识轮次的事务数量限额,包括:
    若所述提案共识结果为提案失败,则获取所述候选投票结果中的建议事务数量;
    根据所述候选投票结果中建议事务数量的总和以及所述候选投票结果的数量,确定第二共识轮次的事务数量限额。
  8. 根据权利要求1至7任一项所述的区块提案方法,所述在所述区块链中广播所述第二区块提案之后,所述方法还包括:
    获取主节点生成的第三区块提案;
    执行所述第三区块提案中的区块链事务,得到所述第三区块提案的执行结果和执行时长;
    根据所述执行结果和所述执行时长,确定本地节点的建议事务数量;
    根据所述第三区块提案的执行结果和所述本地节点的建议事务数量,生成针对所述第三区块提案的节点投票结果;
    在所述区块链中广播所述节点投票结果。
  9. 根据权利要求8所述的区块提案方法,所述根据所述第三区块提案的执行结果和所述本地节点的建议事务数量,生成针对所述第三区块提案的节点投票结果,包括,
    根据所述第三区块提案中区块链事务的执行结果和所述第三区块提案中的提案结果之间的匹配结果,确定针对所述第三区块提案的投票信息;
    根据本地节点的区块链密钥,对所述投票信息进行签名,得到投票签名;
    根据本地节点的区块链密钥,对所述建议事务数量进行签名,得到信息签名;
    根据所述投票信息和所述投票签名以及所述建议事务数量和所述信息签名,生成针对所述第三区块提案的节点投票结果。
  10. 根据权利要求9所述的区块提案方法,所述根据本地节点的区块链密钥,对所述建议事务数量进行签名,得到信息签名,包括:
    获取所述区块链中的当前区块高度以及所述第三区块提案的共识轮数;
    根据本地节点的区块链密钥,对所述建议事务数量、所述当前区块高度和所述共识轮数进行签名,得到信息签名;
    所述根据所述投票信息和所述投票签名以及所述建议事务数量和所述信息签名,生成针对所述第三区块提案的节点投票结果,包括:
    根据所述投票信息和所述投票签名以及所述建议事务数量、所述当前区块高度和所述共识轮数和所述信息签名,生成针对所述第三区块提案的节点投票结果。
  11. 根据权利要求8至10任一项所述的区块提案方法,所述根据所述执行结果和所述执行时长,确定本地节点的建议事务数量,包括:
    根据所述第一提案事务数量、节点能力参数和所述执行时长,确定所述本地节点的候选建议数量,其中,所述节点能力参数是根据所述本地节点的历史事务执行结果确定的;
    若所述执行结果与所述第三区块提案中的提案结果相匹配,则将所述候选建议数量和所述第一提案事务数量中更大的数量作为本地节点的建议事务数量。
  12. 根据权利要求11所述的区块提案方法,所述根据所述执行结果和所述执行时长,确定本地节点的建议事务数量还包括:
    若所述执行结果与所述第三区块提案中的提案结果不匹配,则将所述候选建议数量和所述第一提案事务数量中更小的数量作为本地节点的建议事务数量。
  13. 根据权利要求11或12所述的区块提案方法,所述方法还包括:
    根据所述第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中其他区块链节点的建议事务数量,确定基线数量;
    根据所述基线数量、所述第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果中本地节点的建议事务数量以及所述区块链中提案执行时间阈值,更新所述本地节点的节点能力参数。
  14. 一种区块提案装置,包括:
    获取模块,配置成获取区块链中第一共识轮次内多个区块链节点针对第一区块提案产生的多个投票结果,每个投票结果包含建议事务数量,所述建议事务数量根据所述第一区块提案中的第一提案事务数量、及产生所述投票结果的区块链节点执行所述第一区块提案的执行时长确定;
    生成模块,配置成根据所述多个投票结果各自包含的建议事务数量,生成第二共识轮次的事务数量限额,所述第二共识轮次是所述第一共识轮次的下一共识轮次;
    打包模块,配置成按照所述事务数量限额,将本地事务池中的区块链事务打包,生成供所述区块链中第二共识轮次内多个区块链节点投票的第二区块提案;及
    广播模块,配置成在所述区块链中广播所述第二区块提案。
  15. 一种电子设备,包括:
    处理器;
    存储器,用于存储所述处理器的可执行指令;
    其中,所述处理器配置为经由执行所述可执行指令来执行权利要求1至13中任一项所述的区块提案方法。
  16. 一种计算机可读介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现如权利要求1至13中任一项所述的区块提案方法。
  17. 一种计算机程序产品,计算机程序产品包括计算机程序,计算机程序存储在计算机可读存储介质中,电子设备的处理器从计算机可读存储介质读取并执行计算机程序,使得电子设备执行如权利要求1至13中任一项的区块提案方法。
PCT/CN2025/081601 2024-04-08 2025-03-10 区块提案方法、装置、电子设备和可读介质 Pending WO2025214030A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202410418430.9 2024-04-08
CN202410418430.9A CN120780713A (zh) 2024-04-08 2024-04-08 区块提案方法、装置、电子设备和可读介质

Publications (1)

Publication Number Publication Date
WO2025214030A1 true WO2025214030A1 (zh) 2025-10-16

Family

ID=97292461

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2025/081601 Pending WO2025214030A1 (zh) 2024-04-08 2025-03-10 区块提案方法、装置、电子设备和可读介质

Country Status (2)

Country Link
CN (1) CN120780713A (zh)
WO (1) WO2025214030A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN121619085A (zh) * 2026-01-30 2026-03-06 湘潭大学 一种结合节点贡献机制和二轮共识的区块链分片方法

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019114128A1 (zh) * 2017-12-13 2019-06-20 深圳壹账通智能科技有限公司 区块链事务区块处理方法、电子装置及可读存储介质
CN113626530A (zh) * 2021-09-03 2021-11-09 杭州复杂美科技有限公司 区块生成方法、计算机设备和存储介质
WO2023184881A1 (zh) * 2022-03-30 2023-10-05 杭州趣链科技有限公司 提案共识执行方法、区块链系统、设备和存储介质
CN116977077A (zh) * 2023-06-28 2023-10-31 湖南天河国云科技有限公司 一种区块链共识机制及实现系统、共识节点、区块链系统
CN117155944A (zh) * 2022-05-24 2023-12-01 腾讯云计算(北京)有限责任公司 区块链网络中的交易处理方法、装置、设备以及介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019114128A1 (zh) * 2017-12-13 2019-06-20 深圳壹账通智能科技有限公司 区块链事务区块处理方法、电子装置及可读存储介质
CN113626530A (zh) * 2021-09-03 2021-11-09 杭州复杂美科技有限公司 区块生成方法、计算机设备和存储介质
WO2023184881A1 (zh) * 2022-03-30 2023-10-05 杭州趣链科技有限公司 提案共识执行方法、区块链系统、设备和存储介质
CN117155944A (zh) * 2022-05-24 2023-12-01 腾讯云计算(北京)有限责任公司 区块链网络中的交易处理方法、装置、设备以及介质
CN116977077A (zh) * 2023-06-28 2023-10-31 湖南天河国云科技有限公司 一种区块链共识机制及实现系统、共识节点、区块链系统

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN121619085A (zh) * 2026-01-30 2026-03-06 湘潭大学 一种结合节点贡献机制和二轮共识的区块链分片方法

Also Published As

Publication number Publication date
CN120780713A (zh) 2025-10-14

Similar Documents

Publication Publication Date Title
US20240232223A1 (en) Data synchronization method and system based on blockchain, and related device
CN115378788B (zh) 基于分层共识和强化学习的区块链性能自适应优化方法
CN113055188A (zh) 一种数据处理方法、装置、设备及存储介质
US20200241981A1 (en) Consensus Process Recovery Method and Related Node
WO2024146179A9 (zh) 跨区块链事务处理方法、相关设备、存储介质和产品
WO2023035065A1 (en) Methods and systems for fast consensus within distributed ledgers
WO2025039321A1 (zh) 基于cpe-bft算法的区块链共识机制性能优化方法
US20250184130A1 (en) Blockchain-based key generation method and apparatus
CN115065689B (zh) 一种基于历史评价的联盟链区块数据存储方法及系统
CN114386967B (zh) 跨链资产转移方法、计算机设备和存储介质
CN115296812A (zh) 一种基于区块链的电力数据存储节点高可靠性恢复与校验机制
CN111489156A (zh) 基于区块链的交易方法、电子装置及可读存储介质
US20260005872A1 (en) Data processing method and apparatus based on blockchain
CN120780713A (zh) 区块提案方法、装置、电子设备和可读介质
CN112866399B (zh) 一种改进的pbft共识方法、装置、智能终端及存储介质
CN115842866A (zh) 数据处理方法、装置、计算机可读介质及电子设备
US20230275772A1 (en) Consensus processing method, apparatus, and system for blockchain network, device, and medium
CN118282606A (zh) 一种基于轻量共识的跨链通信方法及系统
CN115271942B (zh) 区块链交易处理方法、装置、电子设备和可读介质
CN116841991B (zh) 链上数据管理方法及其装置、存储介质、程序产品
CN116015614B (zh) 基于区块链系统的密钥处理方法、装置、介质及电子设备
CN117812084A (zh) 一种基于UTXO的Raft共识算法改进方法
CN117336302A (zh) 基于区块链网络的数据处理方法及相关设备
WO2023250103A1 (en) Byzantine fault tolerant blockchain-based state machine replication with optimistic proposals
CN109657447B (zh) 一种设备指纹生成方法及装置

Legal Events

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

Ref document number: 25785510

Country of ref document: EP

Kind code of ref document: A1